mysqli_query采坑记录

使用PHP向mysql插入数据的时候,一直没插入成功:

$username = $_POST['username'];
$password = $_POST['password'];

$connect = mysqli_connect("localhost", "root", "123456", "test", 3306);
echo "
";
var_dump($connect);
echo "
"; echo br; if (!mysqli_errno($connect)) { echo $username . "-----" . $password; mysqli_query($connect, "insert into user_info(username,password) values ($username, $password);"); }

在数据库中查询数据一直查询不到,是因为username和password没用加上引号:

  mysqli_query($connect, "insert into user_info(username,password) values('$username', '$password');");

你可能感兴趣的:(mysql)