我目前正在尝试根据学生编号和密码获得某个用户...问题是mysqli_query一直返回false(?)语句。虽然我通过在PHPMyAdmin中测试它来检查查询。这是我的疑问:
$number = $_POST['number'];
$password = $_POST['password'];
$sql = "SELECT studentNumber FROM student where studentNumber = '$number'" ;
$result = mysqli_query($conn, $sql) or die(mysqli_error());;
if(!$result){
echo "FAIL";
}
else if($result > 0){
header("register.html");
}else{
$sql = "INSERT INTO 'sampleDB'.'student'('userID', 'studentNumber', 'password') VALUES ('', $number, $password)";
header("login.html");
}
这是我的代码连接部分:
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
答案 0 :(得分:0)
首先获取结果并在您的条件下使用它。
$result2 = mysql_fetch_array($result);