The problem I am facing is, mysql_num_rows gives me an output of 1 all through out the code, but when I match it wil 0 in an if statement, it returns true and does the code. so $license returns ........ instead of its actual value.
I tried to debug the problem myself using these.
Any help on this?
$check = mysql_query("SELECT * FROM licenses WHERE email='$email'") or die(mysql_error
());
if (mysql_num_rows($check) > 0)
{
while ($data = mysql_fetch_array($check))
{
print_r($data); // for test
$name = $data['name'];
$license = $data['pid'];
echo $license; // test print 1
$comments = $data['comments'];
}
if ($license == "Sgsmorgan")
$license = "EWP Discounted Basic (Simpleleveraging)";
}
$count = mysql_num_rows($check); // for test
echo $count; // returns 1.
if (mysql_num_rows($check) == 0)
$name = "";
$license = "...........";
echo $license;// test print 2
$comments = "Email doesnt exist in the database";
Surely you mean this:
if (mysql_num_rows($check)==0)
{
$name = "";
$license = "...........";
echo $license; //Test print 2
$comments = "Email doesnt exist in the database";
}
Rather than
if (mysql_num_rows($check)==0)
$name = "";
$license = "...........";
echo $license; //Test print 2
$comments = "Email doesnt exist in the database";
Not using the curly brackets means only the first line below the if
statement is included within it. So $license
is always set to ...........
.
Always use curly brackets.