我有這些錯誤:得到一個錯誤mysql_fetch_array()預計參數1是資源
警告:mysql_fetch_array()預計參數1是資源,布爾在C中給出:\ XAMPP \ htdocs中\店\ lihatBarang.php線14上
警告:mysql_fetch_array()預計參數1是資源,在布爾C中給出:行\ XAMPP \ htdocs中\存儲\ lihatBarang.php 20
這是我的代碼
<?php
#------- memulai page number -------------------------------------------------------------------------------------#
$dataPerPage = 5;
if(isset($_GET['hal']))
{
$noPage = $_GET['hal'];
}else{
$noPage = 1;
}
$offset = ($noPage - 1) * $dataPerPage;
include "koneksi.php";
$ambil_data = mysql_query("select * from store order by id_barang desc limit $offset, $dataPerPage",$koneksi);
$hitung_record = mysql_query("SELECT COUNT(*) AS jumData FROM store",$koneksi);
$data = mysql_fetch_array($hitung_record);
$jumData = $data['jumData'];
$jumPage = ceil($jumData/$dataPerPage);
# ceil digunakan untuk membulatkan hasil pembagian
#------- akhir page number -------------------------------------------------------------------------------------#
while($hasil_data = mysql_fetch_array($ambil_data)){
?>
請不要使用mysql_ *功能,它的棄用,容易受到SQL注入。使用PDO或MySQLi。 – arunrc
計數將返回整數不是數組? –
爲什麼你使用變量$ koneksi? –