php help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

php help

Post 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
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post 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?
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

only as addition to avoid pitfalls
with $a = 0; empty($a) will evaluate to true.
Post Reply