Forum Moderators: coopster
$db = mysql_connect("localhost", "root", "");
if (!$db){
echo "not working";
};
$name=mysql_select_db('greenbelt', $db);
if (!$name){
echo "not working";
};
$sql= mysql_query('Select * From index');
echo "<table border=0><tr><th colspan=2>Upcoming Events</th></tr>";
while (mysql_fetch_array($sql)) {
$id= mysql_result( $q, index.id); // get the field "number"
$title= mysql_result( $q, 2 ); // get the field "title"
$msg= mysql_result( $q, 3 ); // get the field "message"
echo "<tr><td>$id</td><th>$title</th><td>$msg</td></tr>";
}
mysql_close($db);
echo "</table>";
but it gives me this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\admin\admin.php on line 59
which would be this line:
while (mysql_fetch_array($sql)) {
what is wrong?
index is not a good column name, it's a reserved word [dev.mysql.com].