Fatal error: Uncaught Error: Unsupported operand types
Fatal error: Uncaught Error: Unsupported operand types
I need your help please. I got an error about "Unsupported operand types" but i didn't know about it. i've been trying search on google but i'm still can't fix it.
this my error title :
Fatal error: Uncaught Error: Unsupported operand types in
/Applications/XAMPP/xamppfiles/htdocs/aplikasi_penjualan/admin/barang.php:28
Stack trace: #0 {main} thrown in
/Applications/XAMPP/xamppfiles/htdocs/aplikasi_penjualan/admin/barang.php
on line 28
This is code at line 28 : $halaman= ceil($jum / $per_hal);
$halaman= ceil($jum / $per_hal);
and this my code :
<?php include 'header.php'; ?>
<h3><span class="glyphicon glyphicon-briefcase"></span> Data Barang</h3>
<button style="margin-bottom:20px" data-toggle="modal" data-target="#myModal" class="btn btn-info col-md-2"><span class="glyphicon glyphicon-plus"></span>Tambah Barang</button>
<br/>
<br/>
<?php
$periksa=mysqli_query($conn, "select * from barang where jumlah <=3");
while($q=mysqli_fetch_array($periksa)){
if($q['jumlah']<=3){
?>
$(document).ready(function(){
$('#pesan_sedia').css("color","red");
$('#pesan_sedia').append("");
});
<?php
echo "
Stok ". $q['nama']." yang tersisa sudah kurang dari 3 . silahkan pesan lagi !!
";
}
}
?>
<?php
$per_hal=10;
$jumlah_record=mysqli_query($conn, "SELECT COUNT(*) from barang");
$jum=mysqli_fetch_array($jumlah_record);
$halaman= ceil($jum / $per_hal); //-----> THE ERROR IN HERE
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_hal;
?>
<form action="cari_act.php" method="get">
</form>
<br/>
<table class="table table-hover">
<tr>
<th class="col-md-1">No</th>
<th class="col-md-4">Nama Barang</th>
<th class="col-md-3">Harga Jual</th>
<th class="col-md-1">Jumlah</th>
<!-- <th class="col-md-1">Sisa</th> -->
<th class="col-md-3">Opsi</th>
</tr>
<?php
if(isset($_GET['cari'])){
$cari=mysqli_real_escape_string($_GET['cari']);
$brg=mysqli_query($conn, "select * from barang where nama like '$cari' or jenis like '$cari'");
}else{
$brg=mysqli_query($conn, "select * from barang limit $start, $per_hal");
}
$no=1;
while($b=mysqli_fetch_array($brg)){
?>
<tr>
<td><?php echo $no++ ?></td>
<td><?php echo $b['nama'] ?></td>
<td>Rp.<?php echo number_format($b['harga']) ?>,-</td>
<td><?php echo $b['jumlah'] ?></td>
<td>
<a href="det_barang.php?id=<?php echo $b['id']; ?>" class="btn btn-info">Detail</a>
<a href="edit.php?id=<?php echo $b['id']; ?>" class="btn btn-warning">Edit</a>
<a onclick="if(confirm('Apakah anda yakin ingin menghapus data ini ??')){ location.href='hapus.php?id=<?php echo $b['id']; ?>' }" class="btn btn-danger">Hapus</a>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4">Total Modal</td>
<td>
<?php
$x=mysqli_query($conn, "select sum(modal) as total from barang");
$xx=mysqli_fetch_array($x);
echo "<b> Rp.". number_format($xx['total']).",-</b>";
?>
</td>
</tr>
</table>
<ul class="pagination">
<?php
for($x=1;$x<=$halaman;$x++){
?>
<li><a href="?page=<?php echo $x ?>"><?php echo $x ?></a></li>
<?php
}
?>
</ul>
<!-- modal input -->
If either of
$jum
or$per_hal
is not a number you likely get an error, so are they both of type number?– LGSon
Jun 29 at 9:15