Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-15-2002, 10:15 PM   PM User | #1
psings
New to the CF scene

 
Join Date: Aug 2002
Location: Lymington, UK
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
psings is an unknown quantity at this point
php errors

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
psings is offline   Reply With Quote
Old 08-15-2002, 10:46 PM   PM User | #2
mouse
Regular Coder


 
Join Date: Jun 2002
Location: North East England
Posts: 853
Thanks: 0
Thanked 0 Times in 0 Posts
mouse is an unknown quantity at this point
I could be mistaken but you use the variable $result twice for different things.
__________________
[+] Computer/PC issues [+] Silverpaw3D
------------------------------------------------
Never buy a dwarf with learning disabilities...

...it's not big, and it's not clever.
mouse is offline   Reply With Quote
Old 08-15-2002, 11:49 PM   PM User | #3
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
It seems like this line

PHP Code:
$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:

PHP Code:
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.
mordred is offline   Reply With Quote
Old 08-16-2002, 11:27 AM   PM User | #4
psings
New to the CF scene

 
Join Date: Aug 2002
Location: Lymington, UK
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
psings is an unknown quantity at this point
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
psings is offline   Reply With Quote
Old 08-16-2002, 03:47 PM   PM User | #5
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
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.
mordred is offline   Reply With Quote
Old 08-16-2002, 04:11 PM   PM User | #6
psings
New to the CF scene

 
Join Date: Aug 2002
Location: Lymington, UK
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
psings is an unknown quantity at this point
Don't know what's going on but seems to be working now...

Must have been a temporary server glitch


cheers,
Paul
psings is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:11 AM.


Advertisement
Log in to turn off these ads.