Jump to content

mysql_fetch_object():


taurus5_6

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 <[email protected]>");
	}
}
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.