我正在尝试使用PDO连接我的SQL数据库,但无法插入记录。我正在使用带有指定占位符的prepare语句。请更正我要去哪里的地方。
$host = 'localhost';
$username = 'root';
$pass = '';
$db = 'db_pdo';
$dsn = "mysql:host=$host;dbname=$db";
$pdo = new PDO($dsn, $username, $pass);
$sql = "INSER INTO user (user_name, user_phone, user_email, user_city) VALUES (:user_name, :user_phone, :user_email, :user_city)";
$statement = $pdo->prepare($sql);
$statement->bindParam( ':user_name', $user_name );
$statement->bindParam( ':user_phone', $user_phone );
$statement->bindParam( ':user_email', $use_email );
$statement->bindParam( ':user_city', $user_city );
$user_name = 'Test user';
$user_phone = '9998887770';
$use_email = 'test@mailinator.com';
$user_city = 'Test city';
$statement->execute();
echo $statement->rowCount();