i keep getting this error when im trying to insert into Database. "mysqli_select_db() expects exactly 2 parameters, 1 given in"
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="#test"; // Database name
$tbl_name="appoint"; // Table name
// Connect to server and select databse.
$con = mysqli_connect("$host", "$username", "$password")or die("cannot connect");
if(! $con )
{
die('Could not connect: ' . mysql_error());
}
$customer=$_POST['Name'];
$assist=$_POST['Assisstant'];
$service=$_POST['Service'];
$date=$_POST['date'];
$time=$_POST['time'];
$sql="INSERT INTO $tbl_name (cus_name, emp_name, date, time, service)
VALUES ('$customer', '$assist', '$date', '$time', '$service');";
mysqli_select_db("$db_name")or die("cannot select DB");
$retval = mysql_query( $sql, $con );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($con);
You're using it procedurally.
From the docs ;
bool mysqli_select_db ( mysqli $link , string $dbname )
So;
mysqli_select_db($con, $db_name)or die("cannot select DB");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.