Jump to content

[SOLVED] Catchable fatal error: Object of class Message could not be converted to string


Recommended Posts

Hey guys,

Once again i have got stuck on OOP , i don't know why this error is occuring but it is.

 

Here is my code, it is long so below it i have posted the exact line.

 

This is inside a class, called message.

 

<?php
function Send($subject,$message,$to,$from = 0,$check = false,$Alert = false,$read = false)
{
	if(!is_numeric($from))
	{
		$from = GetUserId($from);					
	}

	if(!is_numeric($to))
	{
		$to = GetUserId($to);
	}

	$to = mysql_real_escape_string($to);
	$from = mysql_real_escape_string($from);
	$message = $message;
	$subject = mysql_real_escape_string($subject);		

	$alert = mysql_query("SELECT pm_alert FROM user_preferences WHERE user_id = '".$to."' AND pm_alert = '1' LIMIT 1");

	if(mysql_num_rows($alert) == 1 || $Alert != false)
	{	
		$email = mysql_query("SELECT email FROM user_details WHERE id = '".$to."'");
		$email = mysql_fetch_assoc($email);
		$email = $email['email'];

		$Mail_sub = "New Private Message";

		$Mail_bod = "You have recieved a new private message, you can view the entire message at <a href=\"http://www.americangangsters.org/inbox.php\">http://www.americangangsters.org/inbox.php</a>\r\n<br>The message is from ".CreateUserLink($from)." and reads \r\n<br> ".secure(substr($message,0,(strlen($message) / 2)));

		$Mail_headers  = 'MIME-Version: 1.0' . "\r\n";
		$Mail_headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

		// Additional headers
		$Mail_headers .= 'To: '.GetUserName($to).' <'.$email.'> ' . "\r\n";
		$Mail_headers .= 'From: American Gangsters <blade280891@americangangsters.org>' . "\r\n";

		mail($email,$Mail_sub,$Mail_bod,$Mail_headers);

	}

	if($check == true)
	{

		$subject = trim($subject);
		$message = trim($message);

		$from = trim($from);
		$to = trim($to);

		if(strlen($to) == 0)
			return "<center>Enter a recipient</center>";
		elseif(strlen($subject) == 0)
			return "<center>Enter a subject</center>";
		elseif(strlen($message) == 0)
			return "<center>Enter a message</center>";
		elseif($from == $to)
			return "<center>You can't send to yourself</center>";
		else
		{	
			if($read == true)
			{
				$sql = mysql_query("INSERT INTO user_messages (recipient_id,sender_id,title,body,read_recipt) VALUES ('".$to."','".$from."','".$subject."','".$message."','1')");
			}
			else
			{
				$sql = mysql_query("INSERT INTO user_messages (recipient_id,sender_id,title,body) VALUES ('".$to."','".$from."','".$subject."','".$message."')");
			}

			$sql = mysql_query("INSERT INTO user_messages (recipient_id,sender_id,title,body) VALUES ('".$to."','".$from."','".$subject."','".$message."')");

			mysql_query("UPDATE user_stats SET msgtotal = msgtotal + 1 WHERE user_id = ".$from." ");

			if($sql)
				return "<center>Message Sent</center>";
			else
				return "<center>Message could not be sent</center>";
		}
	}
	else
	{

		if($read == true)
		{
			$sql = mysql_query("INSERT INTO user_messages (recipient_id,sender_id,title,body,read_recipt) VALUES ('".$to."','".$from."','".$subject."','".$message."','1')");
		}
		else
		{
			$sql = mysql_query("INSERT INTO user_messages (recipient_id,sender_id,title,body) VALUES ('".$to."','".$from."','".$subject."','".$message."')");
		}

		mysql_query("UPDATE user_stats SET msgtotal = msgtotal + 1 WHERE user_id = ".$from." ");

		if($sql)
			return "<center>Message Sent</center>";
		else
			return "<center>Message could not be sent</center>";
	}		

}
?>

 

		$Mail_bod = "You have recieved a new private message, you can view the entire message at <a href=\"http://www.americangangsters.org/inbox.php\">http://www.americangangsters.org/inbox.php</a>\r\n<br>The message is from ".CreateUserLink($from)." and reads \r\n<br> ".secure(substr($message,0,(strlen($message) / 2)));

 

Here is where i call it

					echo "<tr><td>".$message->Send($subject,$message,GetUserID($recipient),$_SESSION['user_id'],true)."</td></tr>";

 

There is more but i believe this is all the relevant code.

Link to comment
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.