所以我无法将数据插入我的数据库。我当前的错误是“未选择数据库”错误,但我看不出问题出在哪里。我的代码是:
<?php
$con=mysqli_connect("localhost","root","","db_test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$firstname=$_POST['firstnameReg'];
$surname=$_POST['surnameReg'];
$mypassword=$_POST['passwordReg'];
$email=$_POST['emailReg'];
$result= mysql_query("INSERT INTO tbl_customers (firstname, lastname, email, password) VALUES ('$firstname', '$surname', '$email', '$mypassword'");
echo "$firstname", "$surname", "$mypassword", "$email";
if($result)
{
echo "Success!";
}
else
{
die(mysql_error());
}
mysqli_close($con);
?>
你能看到任何错误吗?我知道它不受 SQL 注入保护,它只是一个测试项目。谢谢你。