0

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

1
  • 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 48 Warning: 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 Commented Aug 19, 2010 at 8:36

2 Answers 2

3

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

Alternatively, use prepared statements.

Sign up to request clarification or add additional context in comments.

2 Comments

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 48 Warning: 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 You need to mysql_real_escape_string after you have established a connection to the database, that's probably your problem.
0

use mysql_real_escape_string

2 Comments

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 48 Warning: 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
he cant open the connection, the user or password wrong, no permission to this user ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.