I am using mysqli
inorder to use database functionality in PHP. So, when I use new mysqli(.,.,.,.,db_name)
, I need to mention db_name
in the begining. I want to create a db after opening a connection. So, obviously I wont be able to give db_name
value while initializing. So, how to initialize a mysqli
variable using which I can create a database $mysqli->query("create database Sample")
, for example.
$mysqli = new mysqli("localhost","root","1sdfd6","Sample","3306");
//How can i provide Sample here when i am creating sample in next statement
$mysqli->query("create database Sample");
$mysqli->select_db("Sample");