im new to php and mysql (using wamp)
im getting the following error when i run my script, any idea what to fix?
Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\wamp64\www\web1\Register.php on line 79
Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\wamp64\www\web1\Register.php on line 81
line 79 t0 83
79 mysqli_select_db($database_localhost, $localhost);
80 $query_Register = "SELECT * FROM mytable";
81 $Register = mysqli_query($query_Register, $localhost) or die(mysql_error());
82 $row_Register = mysql_fetch_assoc($Register);
83 $totalRows_Register = mysql_num_rows($Register);
Here is the database connection:
<?php
# FileName="Connection_php_mysqli.htm"
# Type="mysqli"
# HTTP="true"
$hostname_localhost = "localhost";
$database_localhost = "mydatabase";
$username_localhost = "root";
$password_localhost = "";
$localhost = mysqli_connect($hostname_localhost, $username_localhost, $password_localhost) or trigger_error(mysql_error(),E_USER_ERROR);
?>
As Andrew noted in the comment, the mysql extension was deprecated in PHP 5.5.0 and removed in PHP 7.0.0. You should be using mysqli.
Nonetheless mysql expects the second parameter to be a database resource. You create a resource like this:
then you would select the database with something like