Posted by Sanders Kaufman on 11/20/06 18:20
Akhenaten wrote:
> The following snippet (for whatever reason) returns no value for the
> count. Suggestions?
>
>
> $arr = array ("A", "B", "C", "D", "E");
> foreach ($arr as $client) {
> $count = mysql_query('SELECT COUNT(*) from table where columnA =
> $client');
> echo "$client has $count";
> echo '<br>';
> }
I see no single-quotes around $client in the SELECT
query.
That would make "$client" seem to be a field or
variable name, instead of a string value.
That probably means you're querying for where
columnA = the value of a variable named "$client"
instead of what you meant to query for which was
where columnA = the string in "$client".
I do that so much - it's one of the first errors I
check for anymore!
[Back to original message]
|