sql - PHP MySQL command syntax error -


this sql query not working:

$sql = "insert top(topic_subject,topic_date, topic_cat, topic_by) values(" . mysql_real_escape_string($_post['topic_subject']) . " , now()," . mysql_real_escape_string($_post['topic_cat']) . " , " . isset ($_session['user_id']) . ")"; 

how can fix it?. getting error message.

you have error in sql syntax; check manual corresponds mysql server version right syntax use near ')' @ line 2` 

it's topic_subject character data. include literal strings in sql text, should enclosed in single quotes.

... values ('abc', ... 

if used prepared statements, wouldn't issue, , love of all things beautiful , good in world, don't use deprecated php mysql_ interface new development. it's been superseded mysqli_ , pdo interfaces.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -