Help to understand please! I am writing a simple sniffer for training purposes, which should record user data (ip, client data, time) in the Mysql database. But in the next section of the code

$query = mysqli_query ($dblink, "INSERT INTO 'data' VALUES ('ip', 'usera', 'date')"); mysqli_query ($query, $dblink); mysqli_close ($dblink); 

An error occurs

 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\OpenServer\domains\php.loc\include\sniff.php on line 14 

$ dblink variable is a connection to the database itself, and moved to another file. It connects to the database successfully, but when the script is run, this error occurs.

Closed due to the fact that the participants are off-topic Ipatiev , lexxl , user194374, D-side , cheops 4 Aug '16 at 19:14 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Ipatiev, community spirit, cheops
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    Either "does not connect successfully", or the $ dblink variable is overwritten somewhere along the way. Most likely the first. - Ipatiev

2 answers 2

Immediately after the connection line, make a connection error

 echo mysqli_connect_error(); 

PS And show all the code from the connection string to mysqli_close, or at least the connection string itself

    Thanks for the help! It turned out I had not quite correctly set the query parameters in MySQL in the variable $ query

    • correct answer: the second line in your code is superfluous. - Ipatiev