Hi, I asked this on another forum, and really am just asking for a second opinion before I delete the server software and possibly reinstall earlier versions.
I'm trying to follow the tutorial on http://hotwired.lycos.com/webmonkey/99/21/index3a_page2.html?tw=programming
I'm having some difficulty though. The code I'm using is cut/pasted directly from that page:
<html>
<body>
<?php
$db = mysql_connect("localhost", "root"); mysql_select_db("mydb",$db); // display individual record if ($id) {
$result = mysql_query("SELECT * FROM employees WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
printf("First name: %s\n<br>", $myrow["first"]);
printf("Last name: %s\n<br>", $myrow["last"]);
printf("Address: %s\n<br>", $myrow["address"]);
printf("Position: %s\n<br>", $myrow["position"]);
} else {
// show employee list
$result = mysql_query("SELECT * FROM employees",$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"], $myrow["last"]);
} while ($myrow = mysql_fetch_array($result));
} else {
// no records to display
echo "Sorry, no records were found!";
}
}
?>
</body>
</html>
When I open this page I get:
<html>
<body>
<a href="?id=1">Bob Smith</a><br>
<a href="?id=2">John Roberts</a><br>
<a href="?id=3">Brad Johnson</a><br>
</body>
</html>
Now, no matter which link I click on, I'm presented with the identical list of three links (the address will change from test.php?id=2 to test.php?id=3 etc though). I can query the database fine, as evidenced by the previous tutorial examples working, but this one simply refuses to.
I'm using apache 2.0.45, mysql 4.0.13 and php 4.31 on WinXP Pro SP2.
I was told to replace $PHP_SELF with $_SERVER['PHP_SELF'] but that doesn't make a difference.
Any ideas?