|
Posted by cwhite on 04/02/07 15:11
i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3
mysql 4.1 and apache 2.0.52, and all of the php scripts i had which
called specific entries from mysql are no longer working
if i had a link display_story.php?id=334 it would know do display the
entry which matched id 334, my code to display the entry looks like
this
<?php
$Host="localhost";
$User="user";
$Password="password";
$DBName="database";
$Link=mysql_connect($Host, $User, $Password);
$Query="SELECT * from table WHERE sid=$id;
$Result=mysql_db_query($DBName,$Query, $Link);
while($Row=mysql_fetch_array($Result)){
print("<table width=\"500\">\n");
print("<tr>\n");
print("<td valign=\"bottom\">\n");
print("<p class=\"page_title\">$Row[title]\n");
print("<p>\n");
print("<i>$Row[hometext]</i>\n");
print("</td>\n");
print("<td>\n");
$Topimage=$Row[topic];
include 'top_image.php';
print("</td>\n");
print("</tr>\n");
print("</table>\n");
print("<p>\n");
print("$Row[bodytext]\n");
print("<div align=right><a href=\"javascript: history.go(-1)\">Back</
a></div></td>\n");
}
mysql_close($Link);
?>
the error message in my logs tell me that $Query="SELECT * from table
WHERE sid=$id; is the problem
[client 204.50.205.242] PHP Notice: Undefined variable: id in
**********
[client 204.50.205.242] PHP Warning: mysql_fetch_array(): supplied
argument is not a valid mysql result resource in
*************************** on line 10
i have tried turning on register_globals but the problem persists
any ideas on how i can fix this in php.ini without having to go and re-
write all of my scripts (i'm kind of lazy today)
thanks
[Back to original message]
|