Your missing one variable in your connection:
$link
$link = mysql_connect("localhost","username","password") or die ("Could Not Connect to MySQL");
mysql_select_db("db_name",$link) or die ("Could not Connect to Database");
Also, you are not using mysql_pconnect() for your connection so you do not need mysql_close().
In your while loop, you do not need MYSQL_ASSOC
while ($line = mysql_fetch_array($result)) {
You do not need to break up your $line into a foreach statement.
foreach ($line as $col_value) {
Just use:
echo $line["fieldname"]."<br>";
So to sum it all up:
$link = mysql_connect("localhost","username","password") or die ("Could Not Connect to MySQL");
mysql_select_db("db_name",$link) or die ("Could not Connect to Database");
echo "<table>\n";
$sql = mysql_query("SELECT * FROM tablename ORDER BY fieldname") or die (mysql_error());
while ($row = mysql_fetch_array($sql)) {
echo "<tr>\n";
echo "<td>".$row["fieldname"]."</td>\n";
echo "</tr>\n";
}
echo "</table>\n";