Jump to content

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']);
		}      

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.