newbie help...parse error
| From: | (Edward Peloke) | Date: | Fri, 13 Sep 2002 21:11:35 +0000 |
| Subject: | newbie help...parse error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21745@lists.php.net to get a copy of this message | ||
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>