Home > Database > Mysql Tutorial > body text

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

Patricia Arquette
Release: 2024-10-31 01:37:03
Original
239 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!