bluebyyou Posted October 1, 2008 Share Posted October 1, 2008 I have a basic form to add, edit, delete my websites news from my database. For some when I access the info in my edit form, everything after apostrophes in my title gets lost. It does not happen in the content field. I am doing addslashes() on info going in, and stripslashes() on everything coming out. I'm posting this here because I don think its a mysql problem. Any Ideas? Here is the edit stuff.. $slashed_content = addslashes($_POST['content']); $slashed_title = addslashes($_POST['title']); $query = "UPDATE news SET news_title = '$slashed_title', news_content = '$slashed_content', news_active = '$_POST[active]' WHERE news_id = '$_POST[id]'"; $update_result = mysql_query($query); Here is where I grab it form the DB $slashed_content = addslashes($_POST['content']); $slashed_title = addslashes($_POST['title']); $query = "UPDATE news SET news_title = '$slashed_title', news_content = '$slashed_content', news_active = '$_POST[active]' WHERE news_id = '$_POST[id]'"; $update_result = mysql_query($query); header ('location:index.php'); } else { $news_id = $_GET['id']; $query = "SELECT * FROM news WHERE news_id = $news_id"; $news_result = mysql_query($query); function edit_news($news_result) { $row = mysql_fetch_array($news_result, MYSQL_ASSOC); $print_date = date('F j, Y', strtotime($row['news_date'])); echo "<h2>Edit News</h2>"; echo "<form action='$_SERVER[php_SELF]' method='post'>" ; echo "<input type='hidden' name='action' value='edit'>"; echo "<input type='hidden' name='id' value='".$row['news_id']."'>"; echo $print_date." <input name='title' type='text' value='".stripslashes($row['news_title'])."'>  "; echo "<input name='active' type='radio' value='0'"; if ($row['news_active'] == 0) {echo "checked";} echo "/>Hidden"; echo "<input name='active' type='radio' value='1'"; if ($row['news_active'] == 1) {echo "checked";} echo "/>Active<br /><br />"; echo "<textarea cols='80' rows='10' name='content'>".stripslashes($row['news_content'])."</textarea><br /><br />"; echo "<input name='edit' type='submit' value='Edit'> <a href='index.php'>Cancel</a>"; echo "</form>"; } Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 1, 2008 Share Posted October 1, 2008 If you do a "view source" in your browser, is everything present? If so then you need to use htmlentities() on the data so that special characters in it, like ', ", <, and > are not rendered by the browser. Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted October 1, 2008 Author Share Posted October 1, 2008 Thanks for pointing that out, that worked. 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.