-2

I don't know why it keeps telling me

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\kesedar\Sara_hidup_Rumusan_Tahunan.php on line 189

This is my code:

$query_fasa =  mysql_query("SELECT kodfasa as fasa FROM peneroka_sda WHERE kodrancangan ='".$row_rancangan['kodrancangan']."' AND kodfasa!='' UNION SELECT fasa FROM kodfasa WHERE kodrancangan ='".$row_rancangan['kodrancangan']."' ORDER BY fasa ASC");
$count_fasa=mysql_num_rows($query_fasa);
Bart Friederichs
  • 32,037
  • 14
  • 96
  • 185
  • 1
    **Stop** using deprecated `mysql_*` API. Use `mysqli_*`or `PDO`with prepared statements instead – Jens Jul 28 '16 at 07:49

2 Answers2

0

Check that is the query correct (output the query and run it through MySQL itself), also check why the query fails by using mysql_error(). I advise you to use MySQLi or PDO instead tho.

Janno
  • 540
  • 4
  • 14
0

First, stop using mysql_* they are deprecated. Second, from the docs:

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

Learn to read the docs and figure stuff out for yourself before posting on StackOverflow. We are all more than willing to help, but not with these kind of trivial problems.

Bart Friederichs
  • 32,037
  • 14
  • 96
  • 185