Selasa, 06 Agustus 2013

PHP Indonesia - Facebook: Numpang Tanya: kenapa coding dibawah error ya??? n...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Numpang Tanya: kenapa coding dibawah error ya??? n...
Aug 6th 2013, 13:30, by Kholisoh Imagination

Kholisoh Imagination 1:30pm Aug 6
Numpang Tanya: kenapa coding dibawah error ya??? n warning nya kyak gni :
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\belajarlokomedia\paging_2.php on line 29

codingnya:
<form method=get action=paging_2.php>
Isikan Nama : <input type=text name=nama>
<input type=submit name=oke value=Cari>
</form>
<?php
$oke=$_GET['oke'];
if ($oke=='Cari'){
mysql_connect("localhost","root","");
mysql_select_db("pintar");
//langkah 1
$batas =5;
$halaman=$_GET['halaman'];
if(empty ($halaman)){
$posisi = 0;
$halaman = 1;
}
else {
$posisi=($halaman-1) * $batas;
}
//langkah 2
$nama=$_GET['nama'];
$tampil=mysql_query("select * from anggota where nama like '%$nama%' LIMIT $posisi, $batas");
$jumlah=mysql_num_rows($tampil);

if ($jumlah > 0 ){
echo "<table>
<tr><th>No</th><th>Nama</th><th>Alamat</th></tr>";
$no=$posisi+1;
while( $data = mysql_fetch_array ($hasil)) {
echo "<tr><td>$no</td>
<td>$data[nama]</td>
<td>$data[alamat]</td></tr>";
$no++;
}
echo "<table>";

//langkah 3
$tampil2="select * from anggota where nama like '%$nama%'";
$hasil2 = mysql_query($tampil2);
$jmldata = mysql_num_rows($hasil2);
$jmlhalaman = ceil($jmldata/$batas);
echo "<br>Halaman : ";
$file= "paging_2.php";
for ($i=1; $i<=$jmlhalaman ; $i++)
if ($i != $halaman) {
echo "<a href =$file?halaman=$i&nama=$nama=$nama&oke=$oke>$i</a> | ";
}
else {
echo " <b>$i</b> | ";
}
echo "<p>Ditemukan<b> $jmldata </b> orang dgn nama $nama</p>";
}
else {
echo "Tidak Ditemukan data yang bernama <b>$nama</b>";
}
}
?>

Soesanto Adja 1:35pm Aug 6
$data = mysql_fetch_array ($hasil) <-- query $hasil nya mana?

Edo 1:36pm Aug 6
:v

Gembel Berkelas 1:43pm Aug 6
maunya $hasil atau $tampil ???

Kholisoh Imagination 1:45pm Aug 6
udah berhasil pencerahaannya terima kasih. ane udah ganti $hasil jadi $tampil

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar