grimmy wrote in php

i'm trying to have php go into a database for me, get something out of a table
and then display it for me, but it's not working and i'm really having a hard
time figuring out what exactly the problem is. the code i'm using is practicly
straight out of the book, although with some minor changes.


the error i'm getting is:

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in f:\inetpub\wwwroot\andrew\admin\login_proc.php on line 17


band"


and the whole code for the page is as follows

-------------------------------------------------

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>


<?php

$loginname = $HTTP_POST_VARS["login"];

$password = $HTTP_POST_VARS["pass"];


$db = mysql_connect("localhost", "$loginname", "$password");

mysql_select_db("databasename",$db);

$result = mysql_query("SELECT bandname FROM bands");

echo "<table>";

echo "<tr><td>band</td></tr>";

while ($row = mysql_fetch_array($result))

{

echo "<tr><td>";

echo $row["bandname"];

echo "</td></tr>";

}

echo "</table>";

?>

</body>

</html>

-------------------------------------------------



the error is complaining about this being incorrect:

while ($row = mysql_fetch_array($result))

but that's an unchanged line from the book so it should be correct, shouldn't
it?


if anybody could tell me what the problem is, i'd be most grateful.



[edit] nevermind, i figured it out. it was simply a matter of having "or
die(mysql_error())" at the end of the mysql functions [/edit]


no, wait, that wasn't exactly true.

the _real_ error was that i had put in a wrong name for the database. i changed it at the same time as i added the "or die(mysql_error())" bits and didn't think any more of it. heheheheh, no wonder it didn't want to work