I'm encountering a very strange problem suddenly.
With a single MySql connection file I get no error. but when i use two or more connections files like,
<?php
require_once('Connections/a.php');
require_once('Connections/b.php');
?>
I get a warning something like
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/user/public_html/mydirectory/test.php on line 150
in the following example code. I have indicated where line number 150 is the the following code.
$maxRows_test = 5;
$pageNum_test = 0;
if (isset($_GET['pageNum_test'])) {
$pageNum_test = $_GET['pageNum_test'];
}
$startRow_test = $pageNum_test * $maxRows_test;
mysql_select_db($database_y, $y);
$query_test = "SELECT mytable.id, mytable.title FROM mytable WHERE mytable.id >=1";
$query_limit_test = sprintf("%s LIMIT %d, %d", $query_test, $startRow_test, $maxRows_test);
$test = mysql_query($query_limit_test, $y) or die(mysql_error());
$row_test = mysql_fetch_assoc($test);
if (isset($_GET['totalRows_test'])) {
$totalRows_test = $_GET['totalRows_test'];
} else {
$all_test = mysql_query($query_test);
$totalRows_test = mysql_num_rows($all_test); //////////---->>>>>> Line 150
}
$totalPages_test = ceil($totalRows_test/$maxRows_test)-1;
I can't find out any logic behind such warning. The connection file contains typical mysql connection code like
$hostname_y = "localhost";
$database_y = "abc";
$username_y = "cde";
$password_y = "efg";
$y = mysql_pconnect($hostname_y, $username_y, $password_y) or trigger_error(mysql_error(),E_USER_ERROR);
I went through many similar topics in here but I can't relate the warning with connection files somehow in any of the many topics. This is really very strange.
Any idea?