How is an apostrophe (') used with the WHERE
clause in MySQL?
I have used mysql_real_escape_string
to sanitise input already.
Here is a screenshot of my mySQL query and database
SELECT * FROM players WHERE `name` = 'Amar'e Stoudemire'
Executing this query generates the following error:
Any idea why?
SELECT * FROM players WHERE `name` = 'Amar\\''e Stoudemire'
If your cell content is \'
then you have to escape both characters:
\
--> \\
'
--> ''
I Found my answer thanx for juergen d
who help me out to solve this query
<?php
$name = "Amar'e Stoudemire";
?>
This is the string with Apostrophe
and if you want to check this string in mysql Query with where clause so here is the solution
<?php
$name = addslashes(addslashes($name));
/*Amar\\\'e Stoudemire*/
?>
SELECT * FROM players WHERE `name` = "'.$name.'"
Single quotes can be escaped with themselves in MySQL - like so:
SELECT * FROM players WHERE `name` = 'Amar\''e Stoudemire'