EPCtech Posted July 31, 2008 Share Posted July 31, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/ Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 Well what went wrong? We're not mind readers. Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604747 Share on other sites More sharing options...
EPCtech Posted July 31, 2008 Author Share Posted July 31, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604749 Share on other sites More sharing options...
sasa Posted July 31, 2008 Share Posted July 31, 2008 change $message=$msg['message']; to $message=$row['message']; Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604757 Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604764 Share on other sites More sharing options...
EPCtech Posted July 31, 2008 Author Share Posted July 31, 2008 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! Oh, in that case... Thanks, sasa. But yet, the str_replace("QUOTE","ect",$message); didn't work. Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604768 Share on other sites More sharing options...
sasa Posted July 31, 2008 Share Posted July 31, 2008 can you echo $message before str_replace and post it here Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604776 Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 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']); } Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604782 Share on other sites More sharing options...
EPCtech Posted July 31, 2008 Author Share Posted July 31, 2008 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. EDIT: Papaface, your technique worked. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604783 Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604785 Share on other sites More sharing options...
papaface Posted July 31, 2008 Share Posted July 31, 2008 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']); } Quote Link to comment https://forums.phpfreaks.com/topic/117576-solved-gathering-personal-message-data-echo-it/#findComment-604790 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.