R1der Posted October 3, 2007 Share Posted October 3, 2007 I have spent countless hours tryign to work out the problem here but failed. Please can someone fix this code for me? I get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/*****/public_html/emailall.php on line 14 Mail Sent To . . <?php include("config.php"); $getEMails = Mysql_query("Select * from email"); $loadMails = mysql_fetch_array($GetEMails); { $message = "message here."; $subject = "subject here"; $sendto = "$loadmails"; mail($sendto, $subject, $message, $header); echo "Mail Sent To . $loadMails[email] . "; } ?> Thanks Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 3, 2007 Share Posted October 3, 2007 Change $getEMails = Mysql_query("Select * from email"); To $getEMails = mysql_query("SELECT * FROM email")or die(mysql_error()); That will tell you what is wrong with your query. Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 You always need to check whether the query ran successfully. $getEMails = mysql_query("Select * from email"); if(!$getEMails) { die("Error " . mysql_errno() . ": " . mysql_error()); } $loadMails = mysql_fetch_array($GetEMails); This will tell you why the query failed. Oh, I just saw the bug. You are calling Mysql_query(). The real function is mysql_query() (notice the capitalization). Quote Link to comment Share on other sites More sharing options...
R1der Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks for the replys.. I will start by saying i changed the uppercase "M" to a lowercase but still get the error. ok i also added the code you posted but still get the same error w/out error report Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/r1der1/public_html/emailall.php on line 13 Mail Sent To . . Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Post your new code. Quote Link to comment Share on other sites More sharing options...
R1der Posted October 3, 2007 Author Share Posted October 3, 2007 <?php include("config.php"); $getEMails = mysql_query("Select * from userdb"); if(!$getEMails) { die("Error " . mysql_errno() . ": " . mysql_error()); } $loadMails = mysql_fetch_array($GetEMails); { $message = "ftest."; $subject = "test"; $sendto = "$loadmails"; mail($sendto, $subject, $message, $header); echo "Mail Sent To . $loadMails[email] . "; } ?> Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Well, you changed the table name. I don't know your database, so I don't know if that's a valid table. Try adding a semi-colon at the end of your sql statement. $getEMails = mysql_query("Select * from userdb;"); Quote Link to comment Share on other sites More sharing options...
R1der Posted October 3, 2007 Author Share Posted October 3, 2007 Yea i relized i had the wrong database name in there so changed it . userdb is valid. Change that line of code but still get the same error. Quote Link to comment Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Just for kicks. I added a print_r(). Maybe that will give us more information. <?php include("config.php"); $getEMails = mysql_query("Select * from userdb"); print_r($getEMails); if(!$getEMails) { die("Error " . mysql_errno() . ": " . mysql_error()); } $loadMails = mysql_fetch_array($GetEMails); { $message = "ftest."; $subject = "test"; $sendto = "$loadmails"; mail($sendto, $subject, $message, $header); echo "Mail Sent To . $loadMails[email] . "; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.