im having a hard time coding my php script. it always says "no database selected" but i dont think there is something wrong with my code. here it is:

$con = mysql_connect("localhost","","");
if (!$con)
  die('Could not connect: ' . mysql_error());


$result = mysql_query("SELECT * FROM emptbl") or die(mysql_error());

echo "<table border='1'>";

while($row = mysql_fetch_array($result))
  echo "<tr>";
  echo "<td>" . $row['fname'] . "</td>";
  echo "<td>" . $row['lname'] . "</td>";
  echo "</tr>";
echo "</table>";

Member Avatar

What was your solution?

You really didn't provide the error in which line in the first place.