Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
$name = $_GET['txtName'];
	$email = $_GET['txtEmail'];
	$phone = $_GET['txtPhone'];
	$message = $_GET['txtMessage'];
	$host = 'localhost';
	$user = 'root';
	$password = '07E41A0516';
	$dbSelect = 'gcmas';
	echo $dbc = mysqli_connect($host, $user, $password) or die('Error connecting to database server');
	echo $db = mysql_select_db($dbSelect) or die('Database Not Selected');
	echo $query = "INSERT INTO enquiryform (Name, EmailID, Phone, Message) VALUES ('$name', '$email', '$phone', '$message');";
	echo $result = mysql_query($query, $db) or die( 'Error queriying database'.mysql_error() );

I am getting 'Database Not Selected' error please help...

I tried a lot pages the code is the same but it's not working in my xampp server...
walterhevedeich 2-May-13 22:05pm    
I think it has to do with your PHP version. Try using mysqli_select_db() and mysqli_query().

1 solution

I think it should be

echo $db = mysqli_select_db($dbSelect) or die('Database Not Selected');

you connected to the database using mysqli_connect so try selecting using mysqli_select_db too. and better still specify the database your and connecting to in the mysqli_select_db if you have more than one connected database

echo $db = mysqli_select_db($dbc, $dbSelect) or die('Database Not Selected');

and to remove the database selection part just use

echo $query = "INSERT INTO enquiryform.gcmas (Name, EmailID, Phone, Message) VALUES ('$name', '$email', '$phone', '$message');";

while you remove the mysql_select_db part
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900