I have following piece of code which posts some data into database:
$post = trim( $post );
$post = htmlentities( $post, ENT_QUOTES, null, false );
$statement = "INSERT INTO table (row) VALUES (:message)";
$prepared_posts = $pdo->prepare( $statement );
$prepared_posts->execute( array(开发者_StackOverflow ':message' => $post ) );
I have MySQL version 5.1.47-community
on both localhost and staging / production server, but I'm getting different output on both of them. On localhost I'm running PHP 5.3.2
, production server has PHP 5.2.14
.
If I'm trying to post sentence that's "ok"
, on production it saves that\'s \"ok\"
, localhost produces correct that's "ok"
.
What could be causing this? Could it be some MySQL setting? I also tried using mysqli
instead of PDO
and it does the same thing.
These additional backslashes could be Magic Quotes so that that's "ok"
becomes that\'s \"ok\"
. Try to disable them.
I suppose that magic_quotes_gpc
is on
in production server and in localhost is off
.
You can set it using ini_set
command.
精彩评论