tags:

views:

38

answers:

2

I storing articles in database that contains special characters like ", ', etc. but it gives error while saving in MySQL:

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 and Moral Science's books in school. I clearly remember the picture of a Hindu' at line 1

+3  A: 

mysql_real_escape_string everything you put into a query. Always. No exceptions.

Alternatively, use prepared statements.

deceze
I have used `mysql_real_escape_string` but now it give following error Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\shizin\admin\newArticle.php on line 48Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\shizin\admin\newArticle.php on line 48
amanda
@amanda You need to `mysql_real_escape_string` *after* you have established a connection to the database, that's probably your problem.
deceze
A: 

use mysql_real_escape_string

Haim Evgi
I have used `mysql_real_escape_string` but now it gives following error Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\shizin\admin\newArticle.php on line 48Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\shizin\admin\newArticle.php on line 48
amanda
he cant open the connection, the user or password wrong, no permission to this user ...
Haim Evgi