I'm using PHP to connect with a SQL database using sqlsrv
drivers. However, I've run into a problem:
$string = "Home";
$DBH->prepare( "INSERT INTO table_name (column_name) VALUES ('" .$string. "')" );
$DBH->execute();
How come this works?
$string = "Home's";
$DBH->prepare( "INSERT INTO table_name (column_name) VALUES ('" .$string. "')" );
$DBH->execute();
But this doesn't?
The SQL database doesn't seem to accept the apostrophe in the $string
variable. In the past I would use mysql_real_escape_string
but that isn't an option.