Jump to content

divinedesigns1

Recommended Posts

so i keep getting this error, i try to escaping the double and single quotes but nothing seem to be working but if i remove the single and double quotes myself it gets save no problem

Errors: 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 G-Shock anti-magnetic X-Large G watch features a 51mm wide by 17mm thick black' at line 1

this is the code im using to escape the single and double quotes

$detail = str_replace('"','"',$detail);$detail = str_replace("'","'",$detail); 

any tips or hint will be useful

Edited by DDs1
Link to comment
Share on other sites

You shouldn't have to escape quotes. Use the features built into the database library to handle sanitizing the data. What database library are you using?

  • Like 1
Link to comment
Share on other sites

You shouldn't have to escape quotes. Use the features built into the database library to handle sanitizing the data. What database library are you using?

mysqli

Link to comment
Share on other sites

You shouldn't have to escape quotes. Use the features built into the database library to handle sanitizing the data. What database library are you using?

i sanitized it and that worked

Link to comment
Share on other sites

It's best if you use prepared statements, which completely remove the need to sanitize the data, as stated here: http://php.net/manual/en/mysqli.real-escape-string.php#102639

 

You can't use a string escape to sanitize numbers, for example.

thats what im using, maybe i shouldnt use sanitized to describe the use of mysqli real escape string

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...