Re: Stupid newbie looping MySQL question
| From: | Lynn Siprelle | Date: | Sun, 07 Jan 2001 18:07:43 +0000 |
| Subject: | Re: Stupid newbie looping MySQL question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-5682@lists.php.net to get a copy of this message | ||
>This kind of error happen when you have and invalid query .
>Remember that table names and field names are case sensitive, keywords not.
Having been a *nix admin of one variety or another since '94, I figure EVERYTHING'S
case-sensitive (except me, I'm not being touchy, honest). :) And as a matter of habit I keep
everything lower-case when I'm working with file names and stuff in the shell. Helps me type
faster. That's not the problem here, I'm positive. I can cut-and-paste the query into the
MySQL interface and boom I get three rows.
>If the name of your table "mytable" or the field "name" are not exactly the
>query fails and $result will be null (0) and generate the error : "Supplied
>argument is not a valid MySQL result resource..." when you attempt to use
>$result as an argument to php functions.
>Try this:
>$result = mysql_query ("Select name from mytable") or die(mysql_error());
>if($result){
> while ($row = mysql_fetch_array ($result)) {
> $newTableName = $row['0'];
> $sSQL = "Select id,thread,subject,author,datestamp from
>$newTableName order by datestamp desc limit 30";
> }
>}
Yup, did that on another list member's suggestion and indeed the query is returning zip. WHY is
the question!! There is data in the table, the query is formed correctly, I absolutely positively
know there is a data connection to the server, other material from the same database displays
flawlessly on the same page at the same time as this one fails, if I make the query by hand using
the exact same letters in the exact same order it works. aagh!
I'm sure I have to be doing something wrong, but what? In the words of Spike Jones,
"it's driving me sane!" Thanks for the help, guys.
Lynn
--
Lynn Siprelle, Siprelle & Associates: Web Construction and Publishing
Chief Assoc. Josephine b. 9/9/97 * New Assoc. Louisa due 5/1/01
Business: lynn@siprelle com | Personal: lynsa@siprelle.com
The New Homemaker: http://www.newhomemaker.com/