• PHP Help
  • Warning: mysqli_select_db() expects parameter 1 to be mysqli, null given

hi guys, please I need your help.

how do I fix this error.

Hide Copy Code
Warning: mysqli_select_db() expects parameter 1 to be mysqli, null given

PHP VERSION 7.0

here is my script

Hide Copy Code
<?php
$host="localhost"; // Host name
$dbusername="infin130_ls"; // Mysql username
$dbpassword="admin@001"; // Mysql password
$db_name="infin130_ls"; // Database name

// Connect to server and select databse.
mysql_connect("$host", "$dbusername", "$dbpassword")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

?>

please kindly help with correcting so I can just copy and paste

What I have tried:

Hide Copy Code
hi guys, please I need your help.

how do I fix this error.

<pre>Warning: mysqli_select_db() expects parameter 1 to be mysqli, null given

    I'm confused: your error message cites mysqli_select_db() as the problem, but your code snippet shows you using mysql_select_db() (notice the "i" in the first one). Those are two different things that cannot be intermingled. (The old mysql_*() functions are dead and gone in the latest PHP versions, so you should be using the mysqli_*() functions now -- or PDO instead, which I prefer, but that's sort of a side issue.)

      (Protip: when you copy/paste from CodeProject, replace the text of the "Hide Copy Code" links with the proper [code] markers.)

        Write a Reply...