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

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

mysql_select_db("lola", $con);
if ($_POST)
{ 
$name=$_POST['name'];
$address=$_POST['address'];
$phone=$_POST['phone'];
$iemail= $_POST['Email'];
$pass=$_POST['password'];


$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_close($con); 
  
}
?>

change:

mysql_select_db("lola", $con);

to:

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

<?php
# 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 for diafol

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.