ecabrera Posted December 22, 2011 Share Posted December 22, 2011 ok so when my code dipsplays i get the spaces i add in the db but when i updae it dispalys this rnrnrn and its all together Code <?php include "scripts/connect.php"; if(isset($_GET['edit'])){ $newid = $_GET['edit']; $query = mysql_query("SELECT * FROM news WHERE id='$newid' LIMIT 1"); $rows = mysql_fetch_array($query); $newstitle = $rows['title']; $newsby = $rows['by']; $newsbody = $rows['body']; } if(isset($_POST['saveedit'])){ $newid = mysql_real_escape_string($_POST['saveedit']); $newstitle = mysql_real_escape_string($_POST['title']); $newsby = mysql_real_escape_string($_POST['by']); $newsbody = mysql_real_escape_string($_POST['body']); if ($newstitle && $newsby && $newsbody){ $query = mysql_query("UPDATE news SET title='$newstitle', 'by'='$newsby', body='$newsbody' WHERE id='$newid'") or die(mysql_error()); echo "UPDATE SUCCESFULLY!"; }else $msg = "<font color=red>YOU DID NOT FILL ALL OF THEM IN!</font>"; } ?> <form action='enews.php' method='POST'> <table> <tr> <td></td> <td><?php echo "$msg"; ?></td> </tr> <tr> <td>Article Title</td> <td><input type='text' name='title' size='45' value='<?php echo $newstitle; ?>'/></td> </tr> <tr> <td>By:</td> <td><input type='text' name='by' size='30' value='<?php echo $newsby; ?>' /></td> </tr> <tr> <td>Article Body</td> <td><textarea cols='45' rows='25' name='body'><?php echo stripslashes($newsbody); ?></textarea></td> </tr> <tr> <td><input type='hidden' name='saveedit' value='<?php echo $newid; ?>'/></td> <td><input type='submit' name='updatebtn' value='Update' /></td> </tr> </table> </form> </div> Link to comment https://forums.phpfreaks.com/topic/253644-spaces/ Share on other sites More sharing options...
QuickOldCar Posted December 22, 2011 Share Posted December 22, 2011 If your breaks are saved in database use nl2br() if you need to add a break manually in php code do similar to this $newstitle = $rows['title'] . "<br />"; Link to comment https://forums.phpfreaks.com/topic/253644-spaces/#findComment-1300327 Share on other sites More sharing options...
Pikachu2000 Posted December 22, 2011 Share Posted December 22, 2011 It's because you're using stripslashes(). Link to comment https://forums.phpfreaks.com/topic/253644-spaces/#findComment-1300328 Share on other sites More sharing options...
QuickOldCar Posted December 22, 2011 Share Posted December 22, 2011 Ahh, good find Pikachu2000, I never scrolled that far down the code. Link to comment https://forums.phpfreaks.com/topic/253644-spaces/#findComment-1300330 Share on other sites More sharing options...
ecabrera Posted December 22, 2011 Author Share Posted December 22, 2011 so would i have to remove stripslashes() and use nl2br Link to comment https://forums.phpfreaks.com/topic/253644-spaces/#findComment-1300344 Share on other sites More sharing options...
ecabrera Posted December 22, 2011 Author Share Posted December 22, 2011 CAN SOME ONE HELP ME Link to comment https://forums.phpfreaks.com/topic/253644-spaces/#findComment-1300664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.