|
Posted by Pedro Graca on 11/20/06 19:17
Andy Hassall wrote:
> On Mon, 20 Nov 2006 18:48:39 +0100, Michael Fesser <netizen@gmx.de> wrote:
>>.oO(Christoph Burschka)
>>>Akhenaten wrote:
>>>> The following snippet (for whatever reason) returns no value for the
>>>> count. Suggestions?
>>>> [...]
code re-inserted
>>>> $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>';
>>>> }
>>> 1. You can't pass variables within single quotes.
>>>
>>> 2. Strings in MySQL queries need to be surrounded by quotes
>>
>> 3. mysql_query() just returns a resource ID.
>
> 4. Always check for errors,
5. Indent your code. Always. Even for a very small example posted to
usenet.
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Navigation:
[Reply to this message]
|