Fearpig Posted July 26, 2006 Share Posted July 26, 2006 Hello,I'm currently working through the PHP SQL tutorial at the address below:http://webmonkey.wired.com/webmonkey/99/21/index2a.htmlbut I'm getting stuck on one of the earlier lessons. I've posted my code below (slightly changed from the tutorial). Would someone take a look at it please and see if they spot the problem? When I run the file I get the two following error messages:[color=red]Notice: Undefined variable: id in D:\Intranet v3\php_telephone_list\Lesson4b.php on line 13Notice: Undefined variable: PHP_SELF in D:\Intranet v3\php_telephone_list\Lesson4b.php on line 37[/color]<html><head></head><body><?php$db = mysql_connect("localhost", "root", "password");mysql_select_db("Telephonelist",$db);// display individual recordif ($id) { $result = mysql_query("SELECT * FROM tbl_telephonenumbers WHERE ID=$id",$db); $myrow = mysql_fetch_array($result); printf("First name: %s\n<br>", $myrow["First_Name"]); printf("Last name: %s\n<br>", $myrow["Last_Name"]); printf("Address: %s\n<br>", $myrow["Address_1"]); printf("Position: %s\n<br>", $myrow["Role"]);} else { // show employee list $result = mysql_query("SELECT * FROM tbl_telephonenumbers",$db); if ($myrow = mysql_fetch_array($result)) { // display list if there are records to display do { printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["ID"], $myrow["First_Name"], $myrow["Last_Name"]); } while ($myrow = mysql_fetch_array($result)); } else { // no records to display echo "Sorry, no records were found!"; }}?></body></html> Link to comment https://forums.phpfreaks.com/topic/15703-cannot-locate-error/ Share on other sites More sharing options...
wildteen88 Posted July 26, 2006 Share Posted July 26, 2006 Change $PHP_SELF to $_SERVER['PHP_SELF'] and $id to either $_POST['id'] or $_GET['id']This is becuase webmonkey did this tutorial with register_globals enabled and you dont. I would advise you carrying on with that tutorial as it is out of date. Link to comment https://forums.phpfreaks.com/topic/15703-cannot-locate-error/#findComment-64109 Share on other sites More sharing options...
Fearpig Posted July 27, 2006 Author Share Posted July 27, 2006 Thank you Wildteen....only just started with PHP and I was scratching my head. Do you know of any good up-to-date tutorials? Link to comment https://forums.phpfreaks.com/topic/15703-cannot-locate-error/#findComment-64585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.