|
Posted by Jerry Stuckle on 11/22/05 03:37
Wendy Hoovens wrote:
> Erwin Moller schreef:
>
>> Wendy Hoovens wrote:
>>
>>
>> Hi Wendy,
>> I putted a few suggestion between your lines.
>>
>>
> <snip>
>
>> Also, if you do it like above you will never see where you made the
>> mistake.
>> Simply change to this:
>> $SQL = "SELECT location, COUNT(type) FROM bib WHERE ";
>> $SQL.= "((type='magazine') AND ";
>> $SQL.= "(datum>='$start' AND ";
>> $SQL.= "(datum<='$eind')) GROUP BY location";
>>
>> Before executing, just echo your $SQL:
>> echo $SQL;
>>
>> Simple as that, now you see the SQL you are going to execute and can
>> see the errors right away, like the fact you mixed the words location
>> and locatie.
>>
>> Copy the SQL and try to execute it straight away against the database,
>> using a commandline tool or something. (Depends on your database).
>> ALWAYS just check the SQL when you are uncertain.
>>
>> Then try: mysql_query($SQL);
>>
>>
>>
>>> echo "$result";
>>
>>
>>
>> That doesn't make sense.
>> The $result contains a complex structured array, called a 'resource',
>> that might contain all the rows if the query was succesfull, besides
>> possible other stuff. You cannot just echo it.
>>
>> Try this instead:
>> <pre>
>> <? print_r($result); ?>
>> </pre>
>>
>> Now you get a dump of the $result.
>>
>> If you want to use the $result to display things that your query
>> returned, loop over the resultset.
>> Read on here on how and what and many examples too:
>> http://nl3.php.net/manual/en/function.mysql-query.php
>
>
>
> Thank you for your feedback ERwin! I've been reading about the
> mysql_fetch possibilities but it seems I'm still missing out on
> somethinbg. I know that without the mysql_fetch I can only echo a
> Resource id #x But how does it translate correctly to the actual valuess?
>
> <?
> $SQL = "SELECT loaction, COUNT(type) FROM bib WHERE ";
> $SQL.= "type='magazine' AND ";
> $SQL.= "datum='$start' AND ";
> $SQL.= "datum<='$eind' GROUP BY location";
> echo $SQL;
> $result=mysql_query($SQL);
> while ($row = mysql_fetch_assoc($result)) {
> echo $row['location'];
> echo $row['type'];
> }
> ?>
>
> Kind regards,
>
> Wendy
Wendy,
It doesn't. The resource id is just that - some number which identifies
a resource. A second query which returns the same information may have
a different resource id, while a second query which returns different
information can have the same resource id.
The id is only used to identify which internal resource to use for
further requests, such as mysql_fetch_xxx calls.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|