php 调用未定义的函数 MYSQL_NUM_ROWS()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38306711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Call to undefined function MYSQL_NUM_ROWS()
提问by jafar690
i am trying to validate a login with php but am getting this error :
我正在尝试使用 php 验证登录,但出现此错误:
Fatal error: Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in /opt/lampp/htdocs/social/index.php:100 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/social/index.php on line 100
致命错误:未捕获的错误:调用 /opt/lampp/htdocs/social/index.php:100 中未定义的函数 MYSQL_NUM_ROWS() 堆栈跟踪:#0 {main} 抛出在 /opt/lampp/htdocs/social/index.php在线 100
here is my code
这是我的代码
if(isset($_POST['login'])){
$studentid = $_POST['studid'];
$pass = $_POST['password'];
$query2 = mysqli_query($con, "SELECT * FROM members WHERE student_id = '$studentid' AND password = '$pass' ") or die (mysqli_connect_error());
while($studid = mysqli_fetch_object($query2))
{
echo "$studid->member_id";
}
$numberOfRows = MYSQL_NUM_ROWS($query2);
if ($numberOfRows == 0)
{
}
else if ($numberOfRows > 0){
$wewness = mysql_query("SELECT * FROM members WHERE student_id = $studentid")or die(mysql_error());
$getid = mysql_fetch_array($wewness);
if($getid['account_status']==0){
$_SESSION['login'] = 'maybe';
$_SESSION['member_id'] = $getid['member_id'];
$_SESSION['studentid'] = $getid['student_id'];
header('location:registerexec.php');
}elseif($getid['account_status']==2){
$_SESSION['login'] = 'true';
$_SESSION['member_id'] = $getid['member_id'];
$_SESSION['studentid'] = $getid['student_id'];
header('location:hometest.php');
}elseif($getid['account_status']==1){
$_SESSION['login'] = 'maybe';
$_SESSION['member_id'] = $getid['member_id'];
$_SESSION['studentid'] = $getid['student_id'];
header('location:fill.php');
}
}
}
回答by Rajkumar R
For the PHP version above php 5 we have to use mysqli_ functions
对于 php 5 以上的 PHP 版本,我们必须使用 mysqli_ 函数
mysqli_num_rows()