I need some help with my sql syntax. I am trying to query an MySql database. I already setup the connection etc. I am getting my search parameter from a previous page, and have verified that the parameter is being passed on to the new page. However, something in my syntax is causing an error. Here is the error message I am getting:
This is the default website setupdefault
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/iceregen/public_html/bands/default/index.php on line 12
Notice the first line, that is just some placeholder text I put in there to let me see the new page loading. The 'default' right after the word 'setup', is coming from a passed variable, so that I know the variable is coming across correctly.
Then, there is the error message. Here is the code from the new page, in its entirety.
<?php
session_start();
//read config file
include '../Template/include/config.php';
$_SESSION['website'] = $_GET['website'];
echo 'This is the default website setup';
echo $_SESSION['website'];
$sql = 'SELECT bid, band, theme FROM band WHERE band=' . $_SESSION['website'];
$result = mysql_query($sql);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo $row['bid'];
echo $row['band'];
echo $row['theme'];
}
?>
The echo statements at the bottom are just so I can see if the data is being fetched correctly, but, obviously it is not. The "echo $_SESSION['website']; "
statement is where the passed variable "default" is coming from. Now, I am trying to select the record from the database where the field "band" is equivelant to the passed variable, and I will use the returned information, including the field "theme", to get the css info from the correct directory on my server. I dont know why the query is not working correctly. Any ideas?
Thanks;
Ice