Home >Database >Mysql Tutorial >Why Does mysqli_query() Throw \'mysqli_query() expects at least 2 parameters, 1 given\'?
mysqli_query() Requires Two Parameters
The error "mysqli_query() expects at least 2 parameters, 1 given" indicates that the mysqli_query() function was called with insufficient parameters. According to the PHP manual, mysqli_query() requires two parameters: a MySQLi link identifier and an SQL query.
In the provided PHP script, the mysqli_query() function is invoked on lines 10, 11, and 16 with only one parameter, the SQL query. This will trigger the error. To resolve it, you must provide the MySQLi link identifier as the first parameter to mysqli_query().
The corrected code:
<code class="php">$search_query=mysqli_query($con, $search_sql);</code>
Where "$con" is the MySQLi link identifier representing the connection to the MySQL database.
The above is the detailed content of Why Does mysqli_query() Throw \'mysqli_query() expects at least 2 parameters, 1 given\'?. For more information, please follow other related articles on the PHP Chinese website!