I am just trying a simple code which executes on a form submission ( self). It runs perfect in local. But shows "Error: No database selected" in the remote server. Can anyone say why ?

Thank you

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

mysql_select_db("lola", $con);
if ($_POST)
$iemail= $_POST['Email'];

$sql="INSERT INTO works(name,address,phone,Email,password)VALUES('$name','$address','$phone','$iemail','$pass')";
if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());


mysql_select_db("lola", $con);


mysql_select_db("lola", $con) or die( mysql_error() );

Most likely the user aby does not have any privileges on the lola db.

I cracking my head to solve this problem for days now i need ur help urgently pls. my web page displays no database selected. this is my config

# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_seminary = "localhost";
$database_seminary = "hmuseffu_seminary";
$username_seminary = "hmuseffu_sem";
$password_seminary = "rector123";
$seminary = mysql_pconnect($hostname_seminary, $username_seminary, $password_seminary) or trigger_error(mysql_error(),E_USER_ERROR); 
Member Avatar


Use mysqli instead, but that's not the problem though. Where is your mysql_select_db() function? mysqli is easier...

$link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link));

You then use $link object