ti_nhatrang
09-13-2007, 02:01 AM
this is what I got, but it still doesn't work for me :(
please help, and thanks in advance:
$type = ("new"|"hot"|"warm");
if($he != $type) {$cat = "hot.php"; } elseif {$he == "new") { $cat = "hot.php"; } elseif ($he == "hot") { $cat = "hot.php"; } elseif ($he = "warm") { $cat = "warm.php"; } else { $he = "hot.php" }
dollar
09-13-2007, 03:04 AM
Helps to format the code to try and find where you went wrong (posting errors help as well). It looks like you had the following portion:
elseif {$he == "new")
If you look you'll see you have the curlybrace before $he instead of an open parentheses.
Try this:
$type = ("new"|"hot"|"warm");
if($he != $type) {
$cat = "hot.php";
} elseif ($he == "new") {
$cat = "hot.php";
} elseif ($he == "hot") {
$cat = "hot.php";
} elseif ($he = "warm") {
$cat = "warm.php";
} else {
$he = "hot.php"
}
Jatinder
09-13-2007, 03:42 AM
You should be using switch case instead ifelseifs.
switch($he) {
case 'new':
$cat = "hot.php";
break;
case 'hot':
$cat = "hot.php";
break;
case 'warm':
$cat = "warm.php";
break;
default:
$cat = "hot.php";
}
ti_nhatrang
09-13-2007, 04:41 AM
oh boy ok... let me give this a shot
ti_nhatrang
09-13-2007, 04:52 AM
Warning: include($cat) [function.include]: failed to open stream: No such file or directory in
ti_nhatrang
09-13-2007, 04:54 AM
the reason I want those terms so that nobody can try to do sql injection... so it those terms are not use... I would like it to go to the default file which is hot.php
ti_nhatrang
09-13-2007, 06:21 AM
my apologies, switch worked great!!!
Annex
09-13-2007, 09:01 AM
my apologies, switch worked great!!!
Including just a variable is a very dangerous practice, you should at least have something like this
<?
include ($var . ".php");
?>