-2
你好,我在我的PHP代碼中有一個惱人的錯誤。我問我的老師,他的意思是代碼應該工作,他不知道爲什麼會出現這個錯誤。我希望你能找到的錯誤:
在這個代碼中,我努力成爲一個JSON格式:json不工作,因爲它顯示了一個MySQL數行警告
<?php
$von = $_GET['datumvon'];
$bis = $_GET['datumbis'];
$frei =0;
$DB_server = "localhost";
$DB_name = "dbterminkalenderha";
$DB_user = "root";
$DB_password = "root";
$server = mysqli_connect($DB_server, $DB_user, $DB_password);
$connection = mysqli_select_db($server, $DB_name);
$myquery = $server->prepare("SELECT T_Datum,T_Frei FROM t_terminslots WHERE (T_Datum Between ? AND ?) AND (T_Frei = ?); ");
$myquery->bind_param("ssi",$von,$bis,$frei);
$myquery ->execute();
//$query = mysqli_($myquery);
if (! $myquery) {
echo mysqli_error();
die;
}
$data = array();
for ($x = 0; $x < mysql_num_rows($myquery); $x++) {
$data[] = mysqli_fetch_assoc($myquery);
}
echo json_encode($data);
mysqli_close($server);
?>
錯誤: 警告:mysql_num_rows()預計參數1是資源,對象
你爲什麼要混合mysql_ *函數和mysqli_ *函數? ;) –
你不應該混合mysql和mysqli ... – jeroen
可能的重複http://stackoverflow.com/questions/3434601/warning-mysql-num-rows-expects-parameter-1-to-be-resource – tam5