Hi, I have a form to add news posts to a database. It works fine unless I insert something with slashes, eg. I don't know. When I do, I get:
Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''I don\\'t know ')'., SQL state 37000 in SQLExecDirect in c:\program files\apache group\apache\htdocs\nc\newsform.php on line 51
Post could not be added to database
My code:
if($Submit)
{
$Connect = odbc_connect("News", "NC", "TEST");
$Query = "INSERT INTO News (Author, PostDate, Title, Post)";
$Query .= "VALUES(";
$Query .= "'" . addslashes($Author) . "', ";
$Query .= "now(), ";
$Query .= "'" . addslashes($Title) . "', ";
$Query .= "'" . addslashes($Post) . "')";
if(!(odbc_exec($Connect, $Query)))
{
print("Post could not be added to database");
}
else
{
print("Post added to database");
}
}
What have I done wrong? Any help appreciated, thanx 🙂