Is my php count select correct?

  • Thread starter Thread starter John S
  • Start date Start date
J

John S

Guest
I can't figure why when my array is equal to 0 it still echos yes when it should say no.


$result = mysql_query("SELECT COUNT(*) FROM title WHERE title LIKE '%blue%'");
$array = mysql_fetch_array($result);
echo $array[0];

if ($array = 0) {
echo "yes";
}
else {
echo "no!";
}
Doing what peng says will always give me the else and never the if
 
you can't echo an array()
and you should not use a variable name of $array because that is a reserved word in PHP
do something like
$_array = mysql_fetch_array($result);

and you will have to
if(count($_array) == "0"){
echo "Yes";
}
else{
echo "No!";
}

you will have to
 
Back
Top