Jump to content

Recommended Posts

??? 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;
?>

 

Link to comment
https://forums.phpfreaks.com/topic/65009-mysql_fetch_object/
Share on other sites

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);

Link to comment
https://forums.phpfreaks.com/topic/65009-mysql_fetch_object/#findComment-324442
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/65009-mysql_fetch_object/#findComment-325545
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.