electricphp
Programmer
how come this works:
but this doesn't
even though roshan is inside the table named users
Code:
$existing_users=array('roshan','mike','jason');
$user_name="roshan";
//checking weather user exists or not in $existing_users array
if (in_array($user_name, $existing_users))
{
//user name is not availble
echo "no";
}
else
{
//user name is available
echo "yes";
}
but this doesn't
Code:
$existing_users=array();
$query = "SELECT username FROM users";
$result = mysql_query($query);
while($row=mysql_fetch_row($result))
{
$existing_users[] = $row;
}
mysql_free_result($result);
$user_name="roshan";
//checking weather user exists or not in $existing_users array
if (in_array($user_name, $existing_users))
{
//user name is not availble
echo "no";
}
else
{
//user name is available
echo "yes";
}
even though roshan is inside the table named users