RaythMistwalker Posted January 4, 2010 Share Posted January 4, 2010 I made a PM System for my members, but in order to go into a new paragraph i have to manually add the <br> html tag. Is there a way to replace the return with <br> automatically so that i don't have to type it? Quote Link to comment https://forums.phpfreaks.com/topic/187187-pm-system-update-need-help/ Share on other sites More sharing options...
premiso Posted January 4, 2010 Share Posted January 4, 2010 nl2br on the data when it is displayed will do it. Given that they entered the data in the text field and you did not strip the newline characters (\n). Quote Link to comment https://forums.phpfreaks.com/topic/187187-pm-system-update-need-help/#findComment-988469 Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Author Share Posted January 4, 2010 sorry i don't understand. I didn't strip the newline but where do i put the nl2br() about? Code for displaying message: <?php session_start(); require_once('auth.php'); ini_set('display_errors', 'on'); error_reporting(E_ALL); $id=$_SESSION['SESS_MEMBER_ID']; $mid=$_GET['mid']; include("config.php"); mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); @mysql_select_db(DB_DATABASE) or die( "Unable to select database"); $query="SELECT * FROM messages WHERE msg_id='$mid'"; $result=mysql_query($query) or trigger_error('Query error! Query: <pre>'.$query.'</pre>Reason: ' . mysql_error()); $num=mysql_numrows($result); $readqry="UPDATE messages SET viewed='1' WHERE msg_id='$mid'"; $markasread=mysql_query($readqry); $i=0; while ($i < $num) { $from_id=mysql_result($result,$i,"sender_id"); $to_id=mysql_result($result,$i,"to_id"); $subject=mysql_result($result,$i,"subject"); $message=mysql_result($result,$i,"message"); if ($to_id != $id) { echo "<h1>This isn't Your Message!</h1>"; header("location: message-inbox.php"); exit(); } $query2="SELECT * FROM members WHERE member_id='$from_id'"; $result2=mysql_query($query2) or trigger_error('Query error! Query: <pre>'.$query2.'</pre>Reason: ' . mysql_error()); $sender_firstname=mysql_result($result2,$i,"firstname"); $sender_lastname=mysql_result($result2,$i,"lastname"); mysql_close() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Message</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body text="#0000ff" link="#00a5e9" vlink="#00a5e9" alink="#00a5e9" leftmargin="2" topmargin="2" marginwidth="2" marginheight="0"> <table width=100% class=tableborder> <h1>Message</h1><br> <tr><td><b>From:</b></td><td><? echo $sender_firstname." ".$sender_lastname; ?></td></tr> <tr><td><b>Subject:</b></td><td><? echo $subject; ?></td></tr> <tr><td valign=top><B>Message:</b></td><td><? echo $message; ?></td></tr> <tr><td><input type="button" value="Reply" onClick="location.href='send-message.php?sendto=<? echo $from_id; ?>&subject=<? echo $subject; ?>';"></td></tr></table> <?php ++$i; } ?> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/187187-pm-system-update-need-help/#findComment-988472 Share on other sites More sharing options...
corbin Posted January 4, 2010 Share Posted January 4, 2010 echo nl2br(<variable that contains message from DB>) Quote Link to comment https://forums.phpfreaks.com/topic/187187-pm-system-update-need-help/#findComment-988476 Share on other sites More sharing options...
laffin Posted January 5, 2010 Share Posted January 5, 2010 it really depends on your system You can use nl2br before insertion, so its ready to display, problem is that if u update the msg you have to process it to show original message after a SELECT, its in its orginal form, you have to make it ready for display, but makes updates easier Quote Link to comment https://forums.phpfreaks.com/topic/187187-pm-system-update-need-help/#findComment-988479 Share on other sites More sharing options...
RaythMistwalker Posted January 5, 2010 Author Share Posted January 5, 2010 ok got it and it works perfectly and i don't have it set so users can edit messages they send after they're sent. Quote Link to comment https://forums.phpfreaks.com/topic/187187-pm-system-update-need-help/#findComment-988481 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.