2014-06-09 162 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); 
?> 

試試這個,它會工作。

相關問題