We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,868 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

No Database Selected?

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);
?>
3
Contributors
1
Reply
9 Minutes
Discussion Span
3 Months Ago
Last Updated
4
Views
Question
Answered
lexaeterna
Newbie Poster
5 posts since Feb 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
Question Self-Answered as of 3 Months Ago

What was your solution?

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

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 1.1703 seconds using 2.67MB