Jump to content

[SOLVED] Losing Data Somehow


bluebyyou

Recommended Posts

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'])."'>   &nbsp"; 
		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>";
	}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.