I'm trying to set up a page showing the contents of a database of musical scores I have online but have come across a few problems.
I've got an SQL database with a table within called "list". Within the table I have three fields, "name", "composer" and "price". Using the script below, everything goes fine until I click on the "composer" link in the table (the line saying <td><a href=\"browse_scores.php?composer={$row['composer']}\">{$row['composer']}</a></td>). I get an error message saying "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/surge8.com/c/l/e/clefandstave/htdocs/browse_scores.php on line 33". Anyone got any ideas? Let me know if you need any more details.
if (isset($_GET['composer'])) {
$query = "SELECT * FROM list WHERE list.composer = {$_GET['composer']} ORDER BY list.composer ASC";
} else {
$query = "SELECT * FROM list ORDER BY list.composer ASC";
}
echo '
<div id="body">
<table>
<tr><td>Score</td>
<td>Composer</td>
<td>Price</td>
</tr>';
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr><td><a href=\"view_score.php?name={$row['name']}\">{$row['name']}</a></td>
<td><a href=\"browse_scores.php?composer={$row['composer']}\">{$row['composer']}</a></td>
<td>\£{$row['price']}</td>
</tr>\n";
}
echo '</table></div>';
Thanks,
Sam.
I've got an SQL database with a table within called "list". Within the table I have three fields, "name", "composer" and "price". Using the script below, everything goes fine until I click on the "composer" link in the table (the line saying <td><a href=\"browse_scores.php?composer={$row['composer']}\">{$row['composer']}</a></td>). I get an error message saying "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/surge8.com/c/l/e/clefandstave/htdocs/browse_scores.php on line 33". Anyone got any ideas? Let me know if you need any more details.
if (isset($_GET['composer'])) {
$query = "SELECT * FROM list WHERE list.composer = {$_GET['composer']} ORDER BY list.composer ASC";
} else {
$query = "SELECT * FROM list ORDER BY list.composer ASC";
}
echo '
<div id="body">
<table>
<tr><td>Score</td>
<td>Composer</td>
<td>Price</td>
</tr>';
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr><td><a href=\"view_score.php?name={$row['name']}\">{$row['name']}</a></td>
<td><a href=\"browse_scores.php?composer={$row['composer']}\">{$row['composer']}</a></td>
<td>\£{$row['price']}</td>
</tr>\n";
}
echo '</table></div>';
Thanks,
Sam.