What does depecreated mean?

October 26, 2014 1.9k views

I kept getting that mysql script was deprecated. I did some research and found out that i needed to change the scripts to read as follows.

// Run the actual connection here

mysqliconnect(“$dbhost”,“$dbusername”,“$dbpass”) or die (“could not connect to mysql”);
mysqliselectdb(“$db_name”) or die (“no database”);

But I keep getting this when i try to access the page on chrome.

Warning: mysqliselectdb() expects exactly 2 parameters, 1 given in /var/www/html/storescripts/connecttomysql.php on line 20
no database

Can someone enlighten me.

1 comment
  • You need two parameters.: the connection and the database , so something like:

    // 1. the database connection
    $connection = mysqliconnect($dbhost,$dbusername,$dbpass));
    if (!$connection) { die(“Database connection failed: ” . mysqli
    connect_error()); }

    // 2. select your database
    $yourdb = mysqliselectdb($connection, $dbname);
    if (!$yourdb) { die(“Database selection failed: ” . mysqlierror()); }

1 Answer
Have another answer? Share your knowledge.