Wont display right thing

I am having an issue with this code. Basically I want it to read the business owner name and then see if it matches with the user’s username.

[php]$qBusiness = mysql_query(“SELECT businessOwner FROM businesses”);
while($aBusiness = mysql_fetch_row($qBusiness))
{
if($aBusiness[0] == mysql_real_escape_string($_SESSION[‘username’]))
{
echo “You own a business!”;
break;
}
else
{
echo “You don’t own a business!”;
break;
}
}[/php]

No error message is being thrown at all, it shows “You don’t own a business!” if I have a business or not. It’s getting really annoying.

Hi, I would check a few things if this was my problem,

Is the column “businessOwner” defiantly in position 0 as that’s what $aBusiness[0] is saying.
Is the SESSION[username] set?

Try doing something like this

[php]
$qBusiness = mysql_query(“SELECT businessOwner FROM businesses”);

while($aBusiness = mysql_fetch_row($qBusiness)){

$businessCheck = $aBusiness[‘businessOwner’]

if($businessCheck == mysql_real_escape_string($_SESSION[‘username’]))
{
echo “You own a business!”;
break;
}
else
{
echo “You don’t own a business!”;
break;
}
}

[/php]
Hopefully that helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service