Haig Dedeyan (Home) wrote:
Hi everyone,

I'm a dbase rookie and I've ran into a small problem.

I created a basic faq table and all is fine regarding displaying & searching the Q & A's on a web page.

Up until now, I;ve entered all Q & A's from phpMyAdmin.

I'm trying to create an admin page to enter the Q & A's and for the most part, it's working.

However, I keep getting the following error:

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 's resources than dual monitor mode to generate the video output. Running in dual' at line 2

when I try to add:

Note : Single-monitor mode uses more of your computer's resources than dual monitor mode to generate the video output. Running in dual monitor mode is recommended because it is more efficient.


My PHP code to add Q & A is:

mysql_query("INSERT INTO faqs
(Question, Answer, Category, Date) VALUES('$question', '$answer', '$category', CURDATE() ) ")
or die(mysql_error());

If I enter the above text directly intophpMyAdmin, all is fine.

Firstly more people will see your question if you create a new thread instead of replying to an old one.

The query is getting a double quote, one from:

'$answer'

and one from within answer, so the query is becoming:

'single monitor .... computer's .... '

- the extra quote takes it out of the field and causes an sql error as you see.

Try using http://php.net/mysql_real_escape_string or http://php.net/mysql_escape_string:

$query = "insert into faqs(question, answer, category, date) values ('" . mysql_real_escape_string($question) . "', '" . mysql_real_escape_string($answer) .......

mysql_query($query);


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to