RE: [PHP-DB] Re: Newbie Questions

From: Date: Sun, 05 Sep 2004 22:54:12 +0000
Subject: RE: [PHP-DB] Re: Newbie Questions
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-36060@lists.php.net to get a copy of this message
On Sun, 5 Sep 2004, Pete Holsberg wrote: > Well, I have this: > > $result=mysql_query('SELECT * FROM $table ORDER BY lastname, street, housenum ASC'); > > while ($row=mysql_fetch_assoc($result)) > { > echo $row['lastname'].' '.$row['firstname'].' > '.$row['housenum'].' '.$row['street']; > } > > and I get "Warning: mysql_fetch_assoc(): supplied > argument is not a valid MySQL result resource in > /home/.fanny/pjh/4seasonsatmapleton.org/4sam/directory/showForm-mod.php > on line 26" > > Line 26 is the while statement. > > ???? <blush> I have to learn to keep a 3x5 card with my column headings nearby!! But having corrected that, I'm running into another problem. I added: if (!$result) { echo "Could not successfully run query ($sql) from DB: ". mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } And they output nothing nowm so I assume that there are things to print. But the "while" statement produces nothing also. Also, I think I misunderstood something someone saod earlier. Is it true that the above mysql_query call does not change the way the database is stored by simply sorts the copy that's in memory? Thanks.

« previous php.db (#36060) next »