A JM Posted August 31, 2009 Share Posted August 31, 2009 I'm trying to add breaks to my $comment line but its not working as I anticpiated, can someone help me out with this? It just runs on with breaking after each item in the query...? <?php $query_rstcomments = "SELECT comment FROM comments; $rstcomments = mysql_query($query_rstcomments, $dbconn) or die(mysql_error()); while ($rec=mysql_fetch_assoc($rstcomments)){ $comment = $comment . "\n" . $rec['comment']; } ?> <textarea cols="40" wrap="virtual" disabled="disabled"><?php echo $comment; ?></textarea> Thanks. A JM, Quote Link to comment Share on other sites More sharing options...
Batosi Posted August 31, 2009 Share Posted August 31, 2009 <?php $comment = $comment . "\n" . $rec['comment']; ?> Quote Link to comment Share on other sites More sharing options...
A JM Posted August 31, 2009 Author Share Posted August 31, 2009 Not sure why the backslash didn't show up but that is what I'm currently using? escaping I'm guessing is my problem...? <?php $query_rstcomments = "SELECT comment FROM comments; $rstcomments = mysql_query($query_rstcomments, $dbconn) or die(mysql_error()); while ($rec=mysql_fetch_assoc($rstcomments)){ $comment = $comment . '\n' . $rec['comment']; } ?> Quote Link to comment Share on other sites More sharing options...
Alex Posted August 31, 2009 Share Posted August 31, 2009 At first glance I see 2 things: 1. You're missing a double quote: $query_rstcomments = "SELECT comment FROM comments; should be: $query_rstcomments = "SELECT comment FROM comments"; 2. For a line break "\n" to work it must be wrapped in double quotes, otherwise it'll just be read as a string. So.. $comment = $comment . '\n' . $rec['comment']; Should be: $comment = $comment . "\n" . $rec['comment']; Quote Link to comment 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.