0

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:

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

mysql_select_db('try',$con);

$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>";

mysql_close($con);
?>
2
Contributors
1
Reply
6
Views
4 Years
Discussion Span
Last Post by LastMitch
0

What was your solution?

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.