I'm currently almost done with a new site of mine, but one MySQL insert query is giving me trouble.

The error message I am receiving is : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

The code is:

mysql_query("INSERT INTO Conversations (IP_Address, Question, Answer)
VALUES ('$ip', '$storedquestion', '$answer'")or die(mysql_error());

The problem is with the string $answer to my knowledge. It does contains apostrophes and such, but I couldn't get it to change with the real escape string function.

Any ideas?

Thank you,

Resentful

Recommended Answers

All 5 Replies

try this before inserting:

$answer=addslashes($answer);

try this before inserting:

$answer=addslashes($answer);

It seems to give the same error message.

or try this :

string stripslashes ( string $str )

I think doing that makes it reject it because it leaves apostrophes in it.

It was missing a ")".

Got to love how the littlest mistakes are so easily missed.

Thank you for all of the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.