错误:
警告:mysqli_query()需要至少2个参数,1在第181行的C:\ wamp \ www \ PTT \ forum-categories.php中给出 调用堆栈
# Time Memory Function Location
1 0.0000 273632 {main}( ) ..\index.php:0
2 0.0127 612320 include( 'C:\wamp\www\PTT\forum-categories.php' ) ..\index.php:219
3 0.0156 617456 mysqli_query ( ) ..\forum-categories.php:181**
第181行是:
ORDER BY forum_categorieen.categorie_naam ASC");
编码
<?php
$query = mysqli_query("SELECT forum_categorieen.*, gebruikers.username
FROM forum_categorieen
LEFT JOIN gebruikers
ON forum_categorieen.laatste_user_id = gebruikers.user_id
ORDER BY forum_categorieen.categorie_naam ASC");
答案 0 :(得分:0)
您收到该错误是因为您将错误的参数传递给mysqli_query
函数。
此函数要求第一个参数是mysqli_connect
(链接标识符)的结果,因为在尝试对MySQL服务器运行查询之前必须建立与MySQL服务器的连接,并且第二个参数将是您的SQL查询。
修复后,您的代码将如下所示:
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
$query = mysqli_query($link,
"SELECT forum_categorieen.*, gebruikers.username
FROM forum_categorieen
LEFT JOIN gebruikers
ON forum_categorieen.laatste_user_id = gebruikers.user_id
ORDER BY forum_categorieen.categorie_naam ASC");