title: No Database selected when executing MySQL in php
body: <p>I'm having problems with this php code which needs to create a table in the database specified by the user.  But whenever I try to execute the SQL it tells me no database selected.  My code is as follow  </p>
  
  <pre><code>&lt;?php  
  $con = mysql_connect("127.0.0.1","peter")
  or die('Error connecting to mysql'); // Check connection  
  // Create table 
  mysql_select_db("USE Ebooks");//Select Database
  
  $foldername = mysql_real_escape_string($_POST['foldername']);//Obtain Folder Name 
  
  $sql = sprintf("CREATE TABLE %s (ID CHAR(3) ,Books CHAR(30))", $foldername);  
  mysql_query($sql) or die(mysql_error()); 
  mysql_close($con);  
  ?&gt;
  </code></pre>