RE: [PHP-DB] newbie help...parse error
| From: | John Holmes | Date: | Fri, 13 Sep 2002 21:08:28 +0000 |
| Subject: | RE: [PHP-DB] newbie help...parse error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21746@lists.php.net to get a copy of this message | ||
That usually means your query failed, are you checking for errors using
mysql_error()?
---John Holmes...
> -----Original Message-----
> From: Edward Peloke [mailto:epeloke@echoman.com]
> Sent: Friday, September 13, 2002 5:12 PM
> To: PHP
> Subject: [PHP-DB] newbie help...parse error
>
> ok guys, this code gives me an error of
>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
> result
> resource in c:\program files\apache group\apache\htdocs\classroom.php
on
> line 17
>
> What am I missing, I am sending a username from one screen and wanting
to
> grab the dbname from the table, then get data from the db that is
> specified
> in dbname. I get the dbname fine but then I get errors.
>
> Thanks,
> Eddie
>
>
>
> <html>
>
> <body>
> <?php
> $db = mysql_connect("localhost", "root");
> mysql_select_db("users",$db);
>
> // display individual record
>
> $result = mysql_query("SELECT dbname FROM users WHERE
> username='$username'",$db);
> $myrow = mysql_fetch_array($result);
> printf("DBname: %s\n<br>", $myrow["dbname"]);
>
> ?>
> <?php
> $result=mysql_query("SELECT * from".$myrow["dbname"]."grades");
> $myrow = mysql_fetch_array($result);
> printf("Subject: %s\n<br>", $myrow["subject"]);
> printf("Grade: %s\n<br>", $myrow["grade"]);
> ?>
>
> </body>
> </html>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php