<?php
$link = mysql_connect('localhost', 'root', 'root')
OR die(mysql_error());
mysql_select_db('autos') or die('no db');
$bookName = "O'relly";
$user = addslashes($bookName);
$query = "INSERT INTO makes VALUES(null, '{$user}')";
mysql_query($query) OR die(mysql_error());
var_dump($user);
?>
var转储输出是字符串'O'relly'(长度= 8)但在数据库中存储为'O'relly
在插入数据库之前看起来像 Mysql 带斜杠。这是真的?