Jump to content

Recommended Posts

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>";
}

Link to comment
https://forums.phpfreaks.com/topic/209130-help-for-my-script/
Share on other sites

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>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/209130-help-for-my-script/#findComment-1093213
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.