我有这个代码来搜索和显示来自mysql数据库的数据,我需要将此代码从mysql更改为mysqli,但我有错误,我试图解决它,但我不能。 我的错误类型是致命错误函数名称必须是字符串。 什么是字符串函数和致命错误? 我怎么能再次致命错误:函数名称必须是字符串?
<?php
include('connection.php'); // connect to my database
$submit = $_POST['submit']; // submit
if ($submit){
$search = $_POST['search'];
if(!$search){ // if statment
//echo'ادخل كلمة البحث';
} else {
$sql = "select * from students where St_nationalID ='$search'
or St_name='$search'
or St_surname='$search'
or St_dateOfBirth='$search'
or St_certification='$search'
or St_pointaverage='$search'";// select from my database values
$query = mysqli_query($conn,$sql);
if(mysqli_query($conn,$sql)){ // if statement
$num_rows = mysqli_num_rows($query); //determine number of rows
if($num_rows($query)>0){ // this's the line which have the fatal error
?>
<br><br><br><br><br>
<div class="table"> // div
<table>
<?php
echo"<th>الاسم</th>";
echo"<th>اللقب</th>";
echo"<th>تاريخ الميلاد</th>";
echo"<th>الرقم الوطني</th>";
echo"<th>الشهادة</th>";
echo"<th>سنة التخرج </th>";
echo"<th>المعدل العام</th>";
echo"<th>القسم الدراسي</th>";
while($row = mysqli_fetch_array($query)){ // while loop
//fetch values from my database
$firstname = $row['St_name'];
$surname = $row['St_surname'];
$dateofbirth = $row['St_dateOfBirth'];
$nationalid = $row['St_nationalID'];
$certification = $row['St_certification'];
$graduation = $row['St_YearOfGraduation'];
$pointaverage = $row['St_pointaverage'];
$St_Dep_number = $row['St_Dep_number'];
echo"<tr>";
echo"<td style='border-bottom:1px solid #000;background-color:#A9A9A9;'> $firstname </td>";
echo"<td style='border-bottom:1px solid #000;'> $surname </td>";
echo"<td style='border-bottom:1px solid #000;background-color:#A9A9A9;'> $dateofbirth </td>";
echo"<td style='border-bottom:1px solid #000;'> $nationalid </td>";
echo"<td style='border-bottom:1px solid #000;background-color:#A9A9A9;'> $certification </td>";
echo"<td style='border-bottom:1px solid #000;'> $graduation </td>";
echo"<td style='border-bottom:1px solid #000;background-color:#A9A9A9;'> $pointaverage </td>";
echo"<td style='border-bottom:1px solid #000;'> $St_Dep_number </td>";
echo"</tr>";
?>
</table>
</div> // end of div
<?php
}
} else{ // else statement
echo " لا توجد نتيجة ";
}
}
}
}
exit; // close connection
?>
你知道哪一行产生错误吗? – castis
你能突出显示有错误的行吗? – Vertig0
这很可能是'$ num_rows()'的东西。 – mario