jwilson122 Posted July 28, 2010 Share Posted July 28, 2010 Hey guys! I'm new here, hopefully I'll become an active member here at PHPfreaks! My question is.. WHY does by script show "KK so!\r\n\r\nIDK what to say?\r\n\r\num.." in my message. I'm creating a support ticket system for my users and admin. User side works fine using an while loop in a array. But, on admin side, it displays like that. So obviously the post into the database works fine. My display code is: $ticketslist2 = mysql_query("SELECT * FROM ticket_replies WHERE tid='$tid' AND uid='$uid'"); while ($row = mysql_fetch_array($ticketslist2)) { $id2 = $row['id']; $who2 = $row['who']; $message2 = $row['message']; $subject2 = $row['subject']; $date2 = $row['date']; // Protect against SQL injections $id = mysql_real_escape_string($id2); $who = mysql_real_escape_string($who2); $subject = mysql_real_escape_string($subject2); $message = mysql_real_escape_string($message2); $date = mysql_real_escape_string($date2); echo "Replied by <b>$who</b> on <b>$date</b><br /> <b>Message:</b> $message<br /><br /><hr>"; } Quote Link to comment https://forums.phpfreaks.com/topic/209130-help-for-my-script/ Share on other sites More sharing options...
Pikachu2000 Posted July 30, 2010 Share Posted July 30, 2010 nl2br() is what you need, and see comments within code. <?php $query = "SELECT * FROM ticket_replies WHERE tid='$tid' AND uid='$uid'"; // Separate the query string from the execution, makes debugging easier $ticketslist2 = mysql_query( $query ); // use the value of the $query var in the execution. while ($row = mysql_fetch_array($ticketslist2)) { $id2 = $row['id']; $who2 = $row['who']; $message2 = nl2br($row['message']); // nl2br() function converts newlines to <br /> tags. $subject2 = $row['subject']; $date2 = $row['date']; // Protect against SQL injections ***************** ENTIRELY unnecessary when displaying data, imperative when INSERTING string-type data //$id = mysql_real_escape_string($id2); //$who = mysql_real_escape_string($who2); //$subject = mysql_real_escape_string($subject2); //$message = mysql_real_escape_string($message2); //$date = mysql_real_escape_string($date2); echo "Replied by <b>$who</b> on <b>$date</b><br /> <b>Message:</b>$message<br /><br /><hr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/209130-help-for-my-script/#findComment-1093213 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.