I only have a database and why is it asking for 2 parameters?
Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\video_upload\connect.php on line 5
<?php
mysqli_connect('localhost', 'root', ''); //connecting to the database
mysqli_select_db('video_system'); //chosing a database
?>
the
mysqli_select_db
function, when using the procedural API requires you to pass an actual connection as a first parameter, as shown on the man pages. This connection, or link, is whatmysqli_connect
returns, so you shouldn't ignore whatmysqli_connect
returns, but rather assign it to a variable.The function's signature clearly tells you all of this, so please, RTM. Here's a few copy-pasted exerts:
This means you'll have to write:
Like the manual && signature show, this
mysqli_select_db
returns a bool.true
means the DB was successfully selected,false
indicates failure. It's best to get into the habit of checking function return values. No matter how trivial it may seem. So:But you can easily omit this second function call, by passing the DB name of choice to the
mysqli_connect
function from the off:Which saves you the overhead of an additional function call, which slightly improves performance. I've also changed the
localhost
string to the IP address 127.0.0.1, which can also help, because using the IP means the string needn't be resolved to the corresponding IP address.All in all, I think it best you spend some time reading the documentation