0

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); 
  
}
?>
4
Contributors
3
Replies
19
Views
6 Years
Discussion Span
Last Post by diafol
0

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.

0

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); 
?>

Edited by Dani: Formatting fixed

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.