This mysqli_query
command results in the error below
mysqli_query("INSERT INTO `counter`.`hits` (`page_hits`) VALUES ('".$hits."')");
"Warning: mysqli_query() expects at least 2 parameters, 1 given in"
What does this error message mean, and how can it be fixed?
From the manual
You'll notice the
$link
and$query
variables.This means that you need to pass the function a valid mysqli link resource as well as the query you wish to perform. This lets the function know which established connection to the server to use.
A link resource can be created using:
and an example of how to do so can be found on the aforementioned manual page.
you need to specify the connection that you made to your database somewhere earlier in your page. you should put that variable in the query. Suppose you made a variable called $con. Then your code should be like this.
mysqli_query
excepts 2 parameters , first variable ismysqli_connect
equivalent variable , second one is the query you have providedIt seems you are confusing mysql_query with mysqli_query. The former accepts the sql statement as the first param, while the latter expects a link identifier (created by Mysqli::connect) as the first param and the statement as the second.
The two extensions are not compatable with each other. I suggest you pick one, read the manual pages on how to connect, execute queries, etc, and forget the other exists. which one you pick is up to you, mysqli is more feature rich but more complicated as a result.