|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Stuck on a "not a valid MySQL result resource " error
I'm trying to port over to a new website and get our php scripts to work and most work fine, but one that I have that sorts email addresses and puts them all in the "to" field is frustrating me! I did not write the original code, and I'm learning about PHP & MYSQL as I go.
I'll include all the code here. I've added the "or die .." code, but I keep getting the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/stpaulair/www/pars/spa-admin/test.php on line 19 Any help is appreciated - thanks! Mike =================== <html> <head> </head> <body bgcolor="white"> <? $dbuser = 'web'; $dbhost = 'localhost'; $dbpass = 'passwd'; $dbname = 'mpd'; $dbtable = 'mpr'; $flag=0; //------ DATABASE CONNECTION --------// mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db("mpd"); $sql2 = "SELECT * FROM $dbtable where 'staff'='1'"; $result2 = mysql_query($sql2) or die (mysql_error()); while($value = mysql_fetch_array($result2)) { if ($flag!=0) {$recipients = $recipients . ", " . $value[7];} if ($flag==0) {$recipients = $value[7]; $flag=1;} } $subject = stripcslashes($subject); $message = stripcslashes($message); mail("$recipients","$subject","$message","From: $email"); print("This email has been sent:<br>"); print("<br>To: $recipients<br><br>Subject: $subject<br><br>$message<br>"); ?> </body> </html> |
|
#2
|
|||
|
|||
|
i too have run in to this problem a couple of times. i cannot seem to pinpoint the cause of this either. in my case the 'mysql_query($sql)' returns of type boolean rather than a mysql resource link
my mysql_connect is returning as a mysql resource just fine however. i'll let ya know if i figure this out.. i've never had this problem until recently. |
|
#3
|
||||
|
||||
|
This is often caused by a fault in your SQL statement.
I would recommend checking there first. Try pasting it in the MySQL command line tool and see what gets returned |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Stuck on a "not a valid MySQL result resource " error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|