...

View Full Version : php errors



psings
08-15-2002, 10:15 PM
Hi

I am getting the following error on my php scrips on the top of every page:

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/w........."

Can anybody help me?


Here's part of the code for the main page (the point where the error occurs is in the third code paragraph, and the 4th line down):


mysql_connect("$DBHost","$DBUser","$DBPass");
$old=date("z")-1;
mysql("$DBName","DELETE FROM Users WHERE Date < $old");

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
while ($row=mysql_fetch_row($result)) {
$CII=$row[0];
$CDa=$row[1];
$pieces=explode(":",$CDa);
$DCHK=$pieces[1];
if ($DCHK < $old) {
mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");
}
}


if ($UID != "") {
$result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");
$num=mysql_num_rows($result);
if ($num == "0") {
$dt=date("YmdHis");
$UID="$dt$REMOTE_ADDR";
$date=date("z");
mysql("$DBName","INSERT INTO Users VALUES ('$UID','$date')");
Header("Location: $PHP_SELF?UID=$UID");
}
}



Paul

mouse
08-15-2002, 10:46 PM
I could be mistaken but you use the variable $result twice for different things.

mordred
08-15-2002, 11:49 PM
It seems like this line



$result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");


does not return a valid mysql result list, i.e. something went wrong on the way querying the database. You might check for that case by inserting this after the line mentioned above:



if (!$result) {
echo "sth. went wrong: " . mysql_error();
}


This will print out any errors with the SQL, if there were any, it's quite useful for debugging, I use that always when I develop. The error description should give you a hint what went wrong.

BTW: I don't know of a mysql() function, so I suppose it's one you created. But you definitely don't need the double quotes around the variable $DBName.

psings
08-16-2002, 11:27 AM
I added the mysql_error line and it seems like a table doesn't exist, so I created the table in the database and now keep getting an error saying:


Script Error
The script did not produce proper HTTP headers. Please see the
error log to see the detail of the errors. Depending on the server configuration, you can also run this script under CGIWrap debugging. Usually, either rename or link the script temporarily to a file which ends with .cgid extension, or add a AddHandler cgi-script-debug .cgi line to your .htaccess file.



Anyone?? I have to get this working by the weekend. It works fine locally but not remotely on the server......


Paul

mordred
08-16-2002, 03:47 PM
When exactly do you get this error? I'm quite baffled, I've never seen this error come from incorrect php scripts. Looks to me like your server is not configured properly, but that's hard to determine from distance.

psings
08-16-2002, 04:11 PM
Don't know what's going on but seems to be working now...

Must have been a temporary server glitch


cheers,
Paul



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum