georgeocrawford
Technical User
Hi,
Please help!
I am using this simple script:
At present, this outputs:
I have determined that the problem is with "WHERE group = 'baroque' " - because it works fine when I leave it out. I don't understand - I think this is the correct syntax, but maybe I'm wrong???
Please help!
Please help!
I am using this simple script:
Code:
<html>
<body>
<?php
$db = @mysql_connect("localhost", "username", "password") or
die("could not connect to sql server");
$dbname = @mysql_select_db("database") or
die("could not connect to database");
mysql_select_db("database",$db);
$result = mysql_query("SELECT * FROM repertoire WHERE group = 'baroque' ORDER BY composer ASC",$db);
if (!$result) echo "MySQL query failed!";
echo "<table cellpadding=5>\n";
echo "<tr><td><b>Piece</b></td><td><b>Composer</b></td><td><b>Group</b></td></tr>\n";
while ($myrow = mysql_fetch_array($result) ) {
printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow["piece"], $myrow["composer"], $myrow["group"]);
}
echo "</table>\n";
mysql_close ($db);
?>
</body>
</html>
At present, this outputs:
Code:
MySQL query failed!
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sapphire/public_html/test.php on line 22
I have determined that the problem is with "WHERE group = 'baroque' " - because it works fine when I leave it out. I don't understand - I think this is the correct syntax, but maybe I'm wrong???
Please help!