Warning: mysql_select_db() expects parameter 1 to be string, resource given in C:\xampp\htdocs\my_php_files\php4.php on line 25
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\xampp\htdocs\my_php_files\php4.php on line 26 Could not create table:
The following code is to create a simple database and a table. I'm not able to execute this properly .I've searched many sites to fix this,nothing worked. I'm assuming there are quite a few mistakes .
<?php
//initialization
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '**********';
$dbname = 'data_base';
//check connection
$conn = mysql_connect($dbhost, $dbuser, $dbpass,$dbname);
if(! $conn )
{
die('Could not connect: '. mysql_error());
}
echo 'Connected successfully';
//create table
$sql = 'CREATE TABLE employee( '.
'emp_id INT NOT NULL AUTO_INCREMENT, '.
'emp_name VARCHAR(20) NOT NULL, '.
'emp_address VARCHAR(20) NOT NULL, '.
'emp_salary INT NOT NULL, '.
'join_date timestamp(14) NOT NULL, '.
'primary key ( emp_id ))';
mysql_select_db($conn,$sql);
$retval = mysqli_query("SELECT * FROM employee");
if(! $retval )
{
die('Could not create table: ' . mysql_error());
}
echo "Table employee created successfully
";
mysql_close($conn);
?>
I'm getting errors in the line 25 and line 26 of the program.