转换mysql连接

I have a database connection I'm working on for an old site I'm converting, and I'm trying to update this mysqli_select_db string, but I cant figure out what to put as the variable for the database name now. It USED to be $mysqldb but now that I've changed it to pull from the config.ini file, I dont have a specific variable anymore... or do I? Thanks in advance! I tried googling other answers, but this one is sort of specific.

<?php
$config = parse_ini_file('config.ini'); 
$conn = mysqli_connect($config['mysqlhost'], $config['mysqluser'], $config['mysqlpwd'], $config['mysqldb']) or die(mysqli_connect_error()); 
mysqli_select_db($conn, $mysqldb) or die(mysqli_connect_error());
?>

You don't have to use mysqli_select_db when you choose database in mysqli_connect function.

But if you want do this:

mysqli_select_db($conn, $config['mysqldb']);

this really depends on your config.ini file. As described at http://php.net/manual/en/function.parse-ini-file.php, parse_ini_file converts your ini configuration into an associative array. Your config.ini might look like so:

mysqlhost=localhost
mysqluser=root
mysqlpwd=secret
mysqldb=database_name

If it does, you can use your code as is, except for the mysqli_select_db call, which you have implicitly used in mysqli_connect.

Best regards

you don't have to use mysqli_select_db... Since you have already specify the db in mysqli_connect