|
Posted by Erwin Moller on 04/03/07 10:03
cwhite@theatomicmoose.ca wrote:
> 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
Hi,
Did you print out the POST and GET array?
Above your script:
echo "POST contains:<pre>";
print_r($_POST);
echo "</pre>";
echo "GET contains:<pre>";
print_r($_GET);
echo "</pre>";
If of them contain the id, then your script relies on registering globals.
If so, better fix that and get your data in the right way, with $_GET[] and
$_POST[] supergloabls.
If this is the case, I do NOT understand why enabling register_globals in
php.ini didn't fix it. Did you restart your IIS, or signal apache after
making changes into php.ini??
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|