- Forums
- MYSQL
- Problems Entering Apostrophe In Sql Server
are you having problems inserting data with the apostrophe character into your sql database like mysql [2325], Last Updated: Mon Jun 24, 2024
Webune Support
Tue Mar 02, 2010
0 Comments
580 Visits
Hello, Welcome to Webune.
We provide Excellent SQL Database Hosting -
are you having problems inserting data with the apostrophe character into your sql database like mysql
well, if you are using PHP, you can use the
mysql_real_escape_string() function to clean you string
for example, this is how you would use it
PHP CODE:
$Foo = "Webune's Hosting is the Best!";
$sql = "INSERT INTO mytable SET this=$Foo";
if you were to try to execute the $sql query above, it would error out, so to fix it you would do it like this:
PHP CODE:
$Foo = "Webune's Hosting is the Best!";
$sql = "INSERT INTO mytable SET this=". mysql_real_escape_string($Foo)." ";
or
PHP CODE:
$Foo = mysql_real_escape_string("Webune's Hosting is the Best!");
$sql = "INSERT INTO mytable SET this=$Foo";