Home >Database >Mysql Tutorial >Why Does mysqli_query() Throw \'mysqli_query() expects at least 2 parameters, 1 given\'?

Why Does mysqli_query() Throw \'mysqli_query() expects at least 2 parameters, 1 given\'?

Patricia Arquette
Patricia ArquetteOriginal
2024-10-31 01:37:03314browse

Why Does mysqli_query() Throw

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn