taurus5_6 Posted August 15, 2007 Share Posted August 15, 2007 ??? Why do i get this message? Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/folder/public_html/admin/mail_edit.php on line 41 I tried to change the syntax but still wont work... Here is the code <?php include("globalfn.php"); $mail_id=$_GET["mail_id"]; $subject=$_GET["subject"]; if($REQUEST_METHOD == "POST") { $content = repl_enter($content); $sql = "UPDATE tbl_mail SET subject = '$subject', content = '$content' WHERE mail_id = $mail_id"; put_result($sql); if ($what == 2) { echo("Sending Newsletter..."); $sql = "SELECT email FROM tbl_mailing_list"; $result = put_result($sql); while($row = mysql_fetch_object($result)) { $new_content = str_replace("<br>","\n",$content); mail($row->email,$subject,$new_content,"From: Mywebsite.com <sales@mywebsite.com>"); } } jschangeloc("mail_list.php"); } $sql = "SELECT mail_id, subject FROM tbl_mail WHERE mail_id = $mail_id"; //$sql = "SELECT * FROM tbl_mail WHERE mail_id = $mail_id"; //$result = put_result($sql); $result = mysql_query("$sql"); //while ($row = mysql_fetch_object("$result")) { // echo $row->mail_id; // echo $row->subject; // echo $row->content; //} $row = mysql_fetch_object($result); //echo $row-> mail_id; //echo $row-> subject; //echo $row-> content; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65009-mysql_fetch_object/ Share on other sites More sharing options...
GingerRobot Posted August 15, 2007 Share Posted August 15, 2007 Last time i checked, i wasn't actually psychic. You kinda need to post the actual code. You've given us 31 lines. The error occurs on 41. It would also be useful for you to particularly highlight the line in question. However, i suspect that there is an error in your mysql query. Try adding an or die statement: mysql_query($sql) or die(mysql_error().'<br />'.$sql); Quote Link to comment https://forums.phpfreaks.com/topic/65009-mysql_fetch_object/#findComment-324442 Share on other sites More sharing options...
mmarif4u Posted August 16, 2007 Share Posted August 16, 2007 1st of all ur code is not propor. Let see how? $sql = "SELECT mail_id, subject FROM tbl_mail WHERE mail_id = $mail_id"; //$sql = "SELECT * FROM tbl_mail WHERE mail_id = $mail_id"; //$result = put_result($sql); $result = mysql_query("$sql"); //while ($row = mysql_fetch_object("$result")) { // echo $row->mail_id; // echo $row->subject; // echo $row->content; //} $row = mysql_fetch_object($result); Try it like this: $sql = "SELECT mail_id, subject FROM tbl_mail WHERE mail_id = '$mail_id'"; $result = mysql_query($sql); $row = mysql_fetch_object($result); Hope this will help Quote Link to comment https://forums.phpfreaks.com/topic/65009-mysql_fetch_object/#findComment-325545 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.