apostraphe in MySQL
Moderator: General Moderators
apostraphe in MySQL
Hi, I have come across a problem in MySQL when entering data that contains an apostraphe[ ' ] into a column. I am wondering is there any way to allow a user to enter data containing an apostraphe into a column? Thanks for any help ahead of time.
-
leenoble_uk
- Forum Contributor
- Posts: 108
- Joined: Fri May 03, 2002 10:33 am
- Location: Cheshire
- Contact:
You need to escape it (Put a backslash in front of it)
SET my_column = "Pete''s Stuff"
There's a PHP command called addslashes which does just this for you.
Of course if this statement was in a PHP string you would have to escape the escapement.
$sql = "UPDATE mytable SET my_column = \"Pete\\''s Stuff\" WHERE something=\"$something\" ";
SET my_column = "Pete''s Stuff"
There's a PHP command called addslashes which does just this for you.
Of course if this statement was in a PHP string you would have to escape the escapement.
$sql = "UPDATE mytable SET my_column = \"Pete\\''s Stuff\" WHERE something=\"$something\" ";