Hello to all.
Can anybody please help me to see what is wrong with code written down? This $id is making problems, I'm receiving this error messages:
Notice: Undefined variable: id in C:\Apache2\htdocs\links.php on line 4
Notice: Undefined index: id in C:\Apache2\htdocs\links.php on line 14
I got this code from somewhere on internet, learning Links and am newbie in PHP. Thanks in advance! I use: W2K, MySQL 4.1.0, PHP 4.2.3 (CGI binary), Apache 2.0.43.
<?PHP
$db = mysql_connect("localhost", "root");
mysql_select_db("users",$db);
if ($id) {
$result = mysql_query("SELECT FROM users WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
printf("Name: %s\n<br>", $myrow["name"]);
printf("Email: %s\n<br>", $myrow["email"]);
printf("Password: %s\n<br>", $myrow["pwd"]);
} else {
$result = mysql_query("SELECT FROM users",$db);
if ($myrow = mysql_fetch_array($result)) {
do {
printf("<a href=\"%s?id=%s\">%s</a><br>\n", "$_SERVER[PHP_SELF]" , $myrow["id"], $myrow["name"]);
} while ($myrow = mysql_fetch_array($result));
} else {
echo "Sorry, no records were found!";
}
}
?>