mysql_num_rows () error when using include with localhost

advertisements

I have a Problem when including using localhost. lets say that i have mysql query like this, $strQuery="SELECT employeeName,employeeId FROM employee_tbl where employeeId='$employeeId' ". Then i Use mysql_num_rows() to make sure that employee with that employeeId exist in my database, but when i use the query it says that mysql_num_rows expecting 1 to be result (correct me if im wrong).

It gave me 2 hours headache to fix the problem. First I check the Query, no problem found. Then i Check The Input from HTML input with my var at PHP, nothing wrong. When i cant take the headache anymore i change the Include from localhost to relative path of my app, and IT's WORKED.

i Have no Idea whats wrong. So If you could tell me spesificly it would be nice. Thanks.

As Requested This is My Exact Code :

`<?php
include "localhost/sampleWeb/conf/connection.php";
some code right here
$strQuery="SELECT employeeName,employeeId FROM employee_tbl where employeeId='$employeeId'";
$execQuery=mysql_query($strQuery);
$getData=mysql_num_rows($execQuery)
if ($getData == 0) {
some script done here
} else {
some script done here
}
another code here
?>`

*NOTE : the Error have been fixed, but i have no idea why localhost cause the error. Thats why im asking u too shae your knowledge :D


The error message sounds to me, that you have forgotten to use mysql_query first, before using mysql_num_rows

$strQuery="SELECT employeeName,employeeID FROM employee_tbl where employeeId='$employeeId'";
$result = mysql_query($strQuery);
if(isset($result) {
 $noOfResults = mysql_num_rows($result);
}

But please share complete code to identify your problem exactly.