帮助..我在编码方面是新手,所以我在Google和Youtube上搜索了一些代码。
无论如何,这是我的源代码和错误。(我正在建立数据库)
<?php
$con =mysqli_connect("localhost", "root", "", "student");
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else{
if (isset($_POST['studentno'])) {
$studentno = $_POST['studentno'];
$password = $_POST['password'];
$sql = "select * from data where studentno = '".$studentno."' AND password = ;'".$password."'
limit 1";
$result = mysqli_query($sql);
if (mysqli_num_rows($result)==1){
$message = "Successfully LoggedIn!";
echo "<script type='text/javascript'>alert('$message');</script>";
header('Location: output.html');
exit();
}
else{
$message = "Invalid Student# or Password!!";
echo "<script type='text/javascript'>alert('$message');</script>";
exit();
}
}
}
?>
错误是:
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\Pictures\student.php on line 18
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\Pictures\student.php on line 20
请帮助我...我无法在Google和Youtube上找到任何解决方案...