View Full Version : php errors

08-15-2002, 11:15 PM

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("$DBName","DELETE FROM Users WHERE Date < $old");

$result=mysql("$DBName","SELECT CartItemsID,Date FROM CartItems");
while ($row=mysql_fetch_row($result)) {
if ($DCHK < $old) {
mysql("$DBName","DELETE FROM CartItems WHERE CartItemsID = '$CII'");

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


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

08-16-2002, 12:49 AM
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.

08-16-2002, 12:27 PM
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......


08-16-2002, 04: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.

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

Must have been a temporary server glitch