user2557798
user2557798

Reputation: 21

Arguments in mysql_select_db

Having problems with the arguments in the mysql_select_db

$db_select = mysqli_select_db($connection, my_database);

The second argument is supposed to be the name of the DB (according to W3S)

However, on run I get

Notice: Use of undefined constant my_database - assumed 'my_database' in C:\xampp\htdocs\cag\func.php on line 84

Am I interpreting this error correctly. Or is some other issue at play.

Upvotes: 0

Views: 120

Answers (2)

Nilzone-
Nilzone-

Reputation: 2786

You need your name in quotes (""), or store it in a variable: $temp = "my_database"

Upvotes: 0

Dr_Dang
Dr_Dang

Reputation: 452

Try this

$db_select = mysqli_select_db($connection, "my_database");

or
Better way

$database="name of database";

$db_select = mysqli_select_db($connection, $database);

Upvotes: 3

Related Questions