2014-06-09 160 views
0

我检查记录是否存在:mysql_num_rows导致内部服务器错误

$query = "SELECT * FROM `collegeInfo` WHERE `name` = '$name' "; 
$existed = mysqli_query($con, $query); 
echo mysql_num_rows($existed); 

第三行给我的错误:

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

什么建议吗?谢谢!

+1

您需要添加错误检查。尝试'$ exists = mysqli_query($ con,$ query)或die(mysqli_error($ con));' – Barmar

+0

另外,当您遇到500错误时,您应该检查服务器上的PHP错误日志以获取详细信息。 – Barmar

+0

为什么不回应'mysqli_error($ con)'? –

回答

0

You need to know, you should avoid using mysql and mysqli combined as you have done here:

<?php 
     echo mysql_num_rows($existed); 
?> 

它应该是这样的

<?php 
    echo mysqli_num_rows($existed); 
?> 

试试这个,它会工作。

相关问题