It's hard to tell which output is from which loop, you might be getting
confused (if anything, you might be confusing anyone that might help)...
the Boolean  was probabally due to a bad result, for whatever reason
(maybe your connect code was wrong? I'm not sure but I think you get a
valid resource id even when your connection fails or you don't get any
returs on your query), and the arrays were more than likely empty before
if they didn't contain your results, because mysql_fetch_row returned an
array of nulls (try looping through those arrays, and checking is_null
on the values).

I'll skip the lecture on naming conventions, especially the lengthy
section about other people reading your code.

Without seeing the rest of your script, or your talbe structure, you
might want to try a LEFT JOIN in your query, that will preserve values
that are null. You might also want to use mysql_fetch_array (or
mysql_fetch_object), which I've always used, and never had a problem
getting results from.

I'd be nice to at least see your table structure, then I or anybody else
here could give you a more precise answer. 

I'd suggest looking at the mysql manual entries for SUM, JOIN, LEFT
JOIN, and the php manual entries for mysql_fetch_row, mysql_fetch_array,
and mysql_query. 

Hope this is helpful!

-- Josh

-----Original Message-----
From: John Coder [mailto:jcoder@;] 
Sent: Saturday, November 02, 2002 9:23 PM
Subject: [PHP-DB] boolean instead of array

I seem to somehow get an boolean instead of an array from a
mysql_fetch_row function and I have no idea how.
Here's the code;


$names=mysql_query("select name from dept join picdata where
dept.deptid=picdata.deptid limit 5");

print $names."<p>";
//offending query

$resets=mysql_query("select sum(reset) from Tmp group by deptid order
                    by deptid limit 5");

        //$a[]=$c[0]; commented out for troubleshooting
        print $y."<P>";

      print $z."<br>";
     //$b[]=$e[0]; commented out for troubleshooting

Here's the output from a terminal:

select name from dept join picdata where picdata.deptid=dept.deptid
limit 5;
| name                |
| BodyWatch           |
| BreakThroughGallery |
| TempGallery         |
| KidZone             |
| Lobby               |
5 rows in set (0.01 sec)

here's the output from the browser:

Resource id #3

Any suggestions as to what I'm doing wrong?

John Coder

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to