|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
mysql_num_rows() and mysql_fetch_array() errors
I've googled this site extensively, but can't figure out what's wrong with the script that I'm trying to run.
Here's the code: PHP Code:
This is the error that I get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/random/public_html/promo.php on line 13 So I tried commenting out lines 13-15 if(mysql_num_rows($s)<1){$s=mysql_query("SELECT * FROM users WHERE id=1");} But then running the script gave me this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/random/public_html/promo.php on line 17 I've tried adding or die in various places, but no errors showed up. Any help is greatly appreciated. |
|
#2
|
||||
|
||||
|
The call to mysql_fetch_array() is failing because you commented out the mysql_query(), which fails because you don't have a valid connection to the database. Paste in your db_connect.php (change username and password values) and let's have a look at that.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
This is db_connect.php:
PHP Code:
|
|
#4
|
||||
|
||||
|
Try prepending "@" to all of your mysql functions. The errors you're getting are warnings and so this may just be a matter of your log level being set too high. Sticking "@" at the beginning of the functions should suppress the errors, while having die statements will print out any real problems. I'd recommend adding the output of mysql_error() to your die statements during development.
|
|
#5
|
|||
|
|||
|
Thank you, dhouston.
Can you give me an example of where I should be prepending "@"? |
|
#6
|
||||
|
||||
|
Code:
$connection = @mysql_pconnect("$dbhost","$dbusername","$dbpasswd") or die ("Couldn't connect to server.");
|
|
#7
|
|||
|
|||
|
Error ?
I get some what of the same error mesg.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/main/public_html/Job8/meta.inc on line 7 Is this the same? Thanks |
|
#8
|
||||
|
||||
|
Add the @ sign to that function as well, and to any others that generate the error.
|
|
#9
|
|||
|
|||
|
Changed it..
Ok for this line 7 is:
$meta_row = mysql_fetch_array($meta_return); I changed it to: @meta_row = mysql_fetch_array($meta_return); I get a parse error. I tried $meta_row = @mysql_fetch_array($meta_return); And it went away. Is this ok or just a band aid? Thanks |
|
#10
|
||||
|
||||
|
See response at http://forums.devarticles.com/t9344/s.html. In short, it's somewhere between a band-aid and a fix.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > mysql_num_rows() and mysql_fetch_array() errors |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|