$querypd = "SELECT b.kode_buku FROM buku as b, kategori as k WHERE
				  	    b.kode_kategori=k.kode_kategori AND 
				  	   ((b.kode_buku='{$kodebukupinjaman[0]}' AND b.status='tersedia')OR 
				 	   (b.kode_buku='{$kodebukupinjaman[1]}' AND b.status='tersedia') OR 
				 	   (b.kode_buku='{$kodebukupinjaman[2]}' AND b.status='tersedia') OR
				       (b.kode_buku='{$kodebukupinjaman[3]}' AND b.status='tersedia') OR  
(b.kode_buku='{$kodebukupinjaman[4]}' AND b.status='tersedia'))"; $resultpd=$db->query($querypd); if (!$resultpd) { echo "wrong query"; exit(); } $numrowspd=$resultpd->num_rows; echo "$numrowspd"; // i get 0

why 0 ?
i got the correct numrows (there are records) result when i ran it in sql query program with the same query condition..
the wrong query didn't come up, so there is no problem with the query too.
could anyone help? thanks

    Based on your code I assume that you have a class that handles the database and the functions in it. An example for this is: $resultpd=$db->query($querypd); I don't know exactly what that function does, but if I assume that all database access is through the database class the call of num_rows should look something like:
    $numrowspd=$db->num_rows($resultpd);
    If this does not work then I think you should post the relevant things from the database class for us to be able to help out.

      After you define $querypd, try echoing it so you can verify that all the variable values are set as you are expecting them to be.

        $numrowspd=$db->num_rows($resultpd);


        $numrowspd=$resultpd->num_rows; // this works for sure,since $resultpd is an object too
        i use it frequently..hehehehe

        After you define $querypd, try echoing it so you can verify that all the variable values are set as you are expecting them to be.

        thank you, i found the problems, my array variable ,$kodebukupinjaman is on other part of my script, and the script (the query where i stucked ) got from <a href='peminjaman.php?lanjut=1&var=$namapeminjam,$tanggalpinjam'>

        &var=$namapeminjam,$tanggalpinjam // i include two value i need in <a href='peminjaman.php?lanjut=1
        now i want to pass $kodebukupinjaman too so it can be read.
        i can't do this right?<a href='peminjaman.php?lanjut=1&var=$namapeminjam,$tanggalpinjam,$kodebukupinjaman'>
        if i echo $kodebukupinjaman it will print 'array' so $kodebukupinjaman[0]='a', $kodebukupinjaman[1]='r' and so on. why?
        what is the best way to pass my variable value? using session will be good but i prefer not to use it except there is no other good way...
        my method above is not good for security reason ?
        oh yes,could we use two & sign? (curious) how? like ...&var=$val&var2=$val2 (???)

          Write a Reply...