Aloha everyone,
I have a class assignment in which I am tasked to build a MySql database, then use PHP to retrieve the contents of the table in the database. When I attempt to open this in Safari, it only outputs the HTML/PHP code. Firefox, on the other hand, pops up a window asking me to select an application to work with the code. Here is the code itself. Can anyone see where my error lies and/or point me in the right direction to get this actually interpreted and display correctly? Any and all assistance will be greatly appreciated.
<html>
<head>
<title>iBud's Sizzling Tracks!</title>
</head>
<body>
<?php
$con = mysql_connct("localhost","*****","**************");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("music", $con);
$result = mysql_query("SELECT * FROM songs");
echo "<table border='1'>
<tr>
<th>Song Number</th>
<th>Song Title</th>
<th>Artist</th>
<th>Rating</th>
</tr>";
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['songNumber'] . "</td>";
echo "<td>" . $row['songTitle'] . "</td>";
echo "<td>" . $row['artistName'] . "</td>";
echo "<td>" . $row['rating'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
Is the file name actually .php? And are you running PHP on Apache? Are you viewing the page via the webserver (e.g. http://localhost/index.php).