Jump to content

[SOLVED] Gathering personal message data; Echo it


EPCtech

Recommended Posts

Hi,

I have a code:

	 		{
		$sql=mysql_query("SELECT * FROM pmessages WHERE id=".$_GET['MSGID']." AND recipient='$name'");
		while($row=mysql_fetch_array($sql)) {
		$message=$msg['message'];
		str_replace("<br />","\n",$message);
		str_replace("[quote]","<div id='Quote'><div id='QuoteTitle'>Quote</div>",$message);
		str_replace("[/quote]","</div>",$message);
		echo("Showing message: <b>".$row['title']."</b><br />".$message."<br /><br />This message was sent on ".$row['date']." at ".$row['time']);// } else { echo("You ('".$name."') are not supposed to be reading this."); }
		mysql_query("UPDATE pmessages SET status=0 WHERE id=".$_GET['MSGID']);
		}

It's supposed to:

-Gather MySQL Info

-Make a variable of the message

-Replace some things in the message

-Echo the message

-Set message as "Read"

 

But something went wrong in the process. Could someone see anything wrong?

 

Best Regards,

En-Psyche Management

 

P.S. - Forgot to tell you. It echo's everything BUT the message...

Well what went wrong?

We're not mind readers.

I guess you're not much of a reader either.

P.S. - Forgot to tell you. It echo's everything BUT the message...

Actually I'd typed that before you updated it. The time taken to post is the 2 second difference between my post and your edit!

Try:

	 		{
		$sql=mysql_query("SELECT * FROM pmessages WHERE id=".$_GET['MSGID']." AND recipient='$name'");
		while($row=mysql_fetch_array($sql)) {
		$message=$row['message'];
		$message = str_replace("<br />","\n",$message);
		$message = str_replace("[quote]","<div id='Quote'><div id='QuoteTitle'>Quote</div>",$message);
		$message = str_replace("[/quote]","</div>",$message);
		echo("Showing message: <b>".$row['title']."</b><br />".$message."<br /><br />This message was sent on ".$row['date']." at ".$row['time']);// } else { echo("You ('".$name."') are not supposed to be reading this."); }
		mysql_query("UPDATE pmessages SET status=0 WHERE id=".$_GET['MSGID']);
		}

can you echo $message before str_replace and post it here

Ok, according to the echo tests I did, (An echo every time something happens) no effect took place. AKA the str_replace did nothing.

str_replace in your code won't do anything because its not storing the output in a variable. See my code above and post the result.

Might be better to do:

 		{
		$sql=mysql_query("SELECT * FROM pmessages WHERE id=".$_GET['MSGID']." AND recipient='$name'");
		while($row=mysql_fetch_array($sql)) {
		$message=$row['message']; 
		$find = array("<br /","[quote]","[/quote]"); 
		$replace = array("\n","<div id='Quote'><div id='QuoteTitle'>Quote</div>","</div>");
		$message = str_replace($find,$replace,$message);
		echo("Showing message: <b>".$row['title']."</b><br />".$message."<br /><br />This message was sent on ".$row['date']." at ".$row['time']);// } else { echo("You ('".$name."') are not supposed to be reading this."); }
		mysql_query("UPDATE pmessages SET status=0 WHERE id=".$_GET['MSGID']);
		}      

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.