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 Link to comment https://forums.phpfreaks.com/topic/71673-error-help/ 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. Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360810 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). Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360812 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 . . Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360834 Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 Post your new code. Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360842 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] . "; } ?> Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360848 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;"); Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360852 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. Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360863 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] . "; } ?> Link to comment https://forums.phpfreaks.com/topic/71673-error-help/#findComment-360868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.