Search code examples
phpmysqleditormysql-error-1064

Mysql Error 1064 when trying to save changes in text editor


I'm running this website.

I get a mysql error 1064 when i'm saving changes in my (wysiwyg) text editor

here is the first error

Database error: Invalid SQL: UPDATE page_master SET page_title = 'Help', page_content = '

MySQL Error: 1064 (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 bid online. We do charge tradesmen a small fee for each quote they send. Howev' at line 1) Session halted.

and here is the second error

Database error: Invalid SQL: UPDATE page_master SET page_title = 'Terms and Conditions and use', page_content = '

MySQL Error: 1064 (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 web site is available only to individuals who can form legally binding contrac' at line 1) Session halted.

Here is my sql table.

http://pastebin.com/F15P91TM


Solution

  • As you confirmed my comment above you have to escape the string you want to store in your database.

    There just use the real_escape_string function, see manual: http://www.php.net/manual/en/mysqli.real-escape-string.php

    If you are still using the deprecated mysql_*-functions, you have to use: http://php.net/manual/de/function.mysql-escape-string.php. But again, the use of mysql_* is deprecated and should not be used anymore!