1.11M Members

No Database Selected?

 
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);
?>
Question Self-Answered as of 1 Year Ago
LastMitch
Deleted Member
 
0
 

What was your solution?

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: