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@;insightbb.com] 
Sent: Saturday, November 02, 2002 9:23 PM
To: [EMAIL PROTECTED]
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;

<?
<snip>

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

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

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

while($c=mysql_fetch_row($names));
        {
        //$a[]=$c[0]; commented out for troubleshooting
        $y=gettype($c);
        print $y."<P>";
        }

while($e=mysql_fetch_row($resets))
     {
      $z=gettype($e);
      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
boolean
array
array
array
array
array


Any suggestions as to what I'm doing wrong?

John Coder






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to