Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2002091

[PHP-DB] newbie help...parse error From: Edward Peloke (epeloke <email protected>)
Date: 09/13/02

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