Page 1 of 1

php help

Posted: Mon Feb 10, 2003 3:21 pm
by forgun

Code: Select all

if (!isset($idpage)) {
	header("location: http://" .$_SERVERї'HTTP_HOST'] .$_SERVERї'PHP_SELF'] . "?type=htm/php&idpage=main");
} 
include("includes/dbs.php");
$lk = mysql_connect($serv,$user,$pass) or die (mysql_error());
mysql_select_db($dbnameї0],$lk);
switch ($type) {
	case "htm/php":
	$qur = "select id , kayword , path from linkssets  order by id desc ";
	$res = mysql_query($qur) or die (mysql_error());
	$row = mysql_fetch_assoc($res);
	$idї] = $rowї'id'];
	$keyї] = $rowї'keyword'];
	$pathї] = $rowї'path'];
	foreach ($id as $val => $kays) {
	if ($idpage == $pathї$val]) {
		$inc = $pathї$val]; #line of the prob
		
	}
	}
}
i try to look for a prob and i dont fing the prob
the prob that it's not set inc at all

Posted: Mon Feb 10, 2003 6:28 pm
by Zoram
try printing your $path[$val] and $idpage variables and see what they are before the if statement

also is it keys instead of kays in the foreach?

Posted: Mon Feb 10, 2003 9:32 pm
by Stoker
isset() doesnt guarantee that the variable has anything in it, so a http://host/dir/fil?idpage= could possibly cause odd behaviour?

if (empty($idpage)) {
$idpage = 'main';
$type = 'htm/php';
}


instead of redirecting the browser causing delay and bandwith waste, just set $idpage and let the script continue

Posted: Mon Feb 10, 2003 10:00 pm
by volka
only as addition to avoid pitfalls
with $a = 0; empty($a) will evaluate to true.