help: register_global=off, I can not get URL
I set register_global=off in php.ini file, and I found my codes as
below does not work:
================================================== =================
<html>
<body>
<?php
$myid=$_GET['myid'];
$db = mysql_connect("localhost", "root", "949701");
mysql_select_db("school",$db);
if ($myid) {
$result = mysql_query("SELECT * FROM teacher WHERE id=$myid",$db);
$myrow = mysql_fetch_array($result);
printf("name: %s\n<br>", $myrow["name"]);
printf("address: %s\n<br>", $myrow["address"]);
printf("year: %s\n<br>", $myrow["year"]);
}
else
{
$result = mysql_query("SELECT * FROM teacher",$db);
if ($myrow = mysql_fetch_array($result))
{
do {
printf("<a href=\"%s?$myid=%s\">%s %s</a><br>\n",$_SERVER['PHP_SELF'],
$myrow["id"], $myrow["name"], $myrow["address"]);
} while ($myrow = mysql_fetch_array($result));
}
else
{
echo "sorry no records!";
}
}
?>
</body>
</html>
================================================== ==================
The error is as below:
Notice: Undefined index: myid in D:\Apache Group\Apache2\htdocs\tt.php on line 6
I don't know how to define the variable "myid" when register_global=off. and my intention in my above code is to
get the related record through "myid".
Thanks in advance!
|