I am having an issue when I submit a news item with a ' in it. I post something like "I am having a good day. We'll have a good week". It errors on the "we'll". It causes an error and says there is a SQL syntax error. Not sure how to fix it. I thought it was a stripslashes problem or a htmlentities or specialchars problem but i can't seem to figure it out.
Any help is appreciated.
<?php
if (isset($_POST['submit']))
{
require_once ('db_connect.php');
mysql_select_db("my_news");
$date = date("ymd");
$ntime = date("g:i a");
$fbody = stripslashes($body);
$query = "INSERT INTO news (ndate, ntime, subject, body, auth) VALUES ('$date', '$ntime', '$subject', '$fbody', '$auth')";
$result = @ ($query);
if ($result)
{
echo "Added $subject to the news database!";
}
else
{
echo "Something went wrong <br>";
echo mysql_error();
}
mysql_close();
}
else
{
?>