joesoaper Posted April 7, 2017 Share Posted April 7, 2017 I have a textarea for notes. When I enter or paste text into this field it all shows on one line. For example I enter Line 1 Line 2 Line 3 When it is updated it shows as - Line 1 Line 2 Line 3 - while I actually want it to show as it was originally copied or pasted in. After several days of trying different options I am stumped. This is the code I am using currently is as follows: include("connect.php"); $uniq = $_GET['uniq']; $staff = $_POST['staff']; $notes = $_POST['notes']; $notesupdated = $_POST['notesupdated']; $result = mysql_query("SELECT * FROM new_notes WHERE uniq = '$uniq' ORDER BY notesupdated ASC"); $num = mysql_num_rows ($result); if ($num > 0 ) { $i=0; while ($i < $num) { $unik = stripslashes(mysql_result($result,$i,"unik")); $staff = stripslashes(mysql_result($result,$i,"staff")); $notes = stripslashes(mysql_result($result,$i,"notes")); $notesupdated = stripslashes(mysql_result($result,$i,"notesupdated")); $row .= '<tr bgcolor=" #ffffff"> <td valign="top" width="4">'.$staff.'</td> <td valign="top" width="4">@</td> <td align="left" width="100%">'.$notesupdated.'</td> </tr> <tr> <td width="400" colspan="5">'.$notes.'</td> </tr>' ; ++$i; }} else { $row = '<tr><td colspan="2" align="center">Nothing added yet</td></tr>'; } ?> As always any help or advice greatly appreciated Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 7, 2017 Share Posted April 7, 2017 you are displaying the content using html. in html, a new line is a <br> tag. see php's nl2br() function. next, your most recent threads on the forum have been using the php PDO extension. why have you reverted to obsolete and insecure code using the php msyql extension? Quote Link to comment Share on other sites More sharing options...
joesoaper Posted April 7, 2017 Author Share Posted April 7, 2017 Sorry my bad... I am currently changing everything over to PDO this little bit of code has not been done yet. Would you recommend I suspend this thread until I have done it in PDO or can I still use the solution in PDO? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted April 7, 2017 Share Posted April 7, 2017 The code is fudged up beyond repair. It was obviously written for the ancient Magic Quotes feature which doesn't even exist today (it was removed back in 2009). Now you're wide open to SQL injection attacks, and the stripslashes() stuff will damage your data. Your HTML markup is even older. Visual attributes like bgcolor were deprecated in 1997! So either the application hasn't been touched in the last 20 years, or you really need to update your knowledge. In any case, expect a major rewrite. 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.