How To Insert The Apostrophe Character MySQL database
- Forums
- MYSQL
- How To Insert The Apostrophe Character MySQL database
I Am Trying To Insert The Post Data From My Php Form Into Mysql Db To Insert Special Characters, Like The "apostrophe" Read The Section On String [2321], Last Updated: Mon Jun 24, 2024
Junki1999
Mon Jan 11, 2010
6 Comments
2471 Visits
How do you insert text with apostrophe into a mysql table? I am using PHP and MySQL table to insert data into my database, but when i submit the HTML form, it works except the problem happens when i try to enter the apostrophe (') charater into the SQL database. so how do i dela with insterting apostrophe's characters.
i have tried all the tricks, but none seem to work. although, i must say that i am new to php and mysql so if you can show me how to sql insert string apostrophe using php mysql to insert apostrophe that would be great. i will try to learn more about sql server and how to insert apostrophes. i do have a little expirience in oracle sql insertion but never run into a problem with apostrophe, only with quotes, i did but i was able to use the htmlentities() function, and that worked. but now its the sql insert with apostrophe issue.
please help
mysql_real_escape_string()
you need to use mysql_real_escape_string() function to escape all the characters in your database
for example:
$foo = "This is a Webune's Tutorial";
$sql = "INSERT INTO mytable SET comments = '".mysql_real_escape_string($foo)."'";
you see?