PHP 致命错误:函数名必须是字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20156760/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:55:43  来源:igfitidea点击:

PHP Fatal error: Function name must be a string

php

提问by Mark Hedberg

    $img1 = $_GET['img1'];
    $img2 = $_GET['img2'];
    $query = $mysql_query("SELECT * FROM asd WHERE ID=$img1");
    $row1 = mysql_fetch_array($query);
    $query = $mysql_query("SELECT * FROM asd WHERE ID=$img2");
    $row2 = mysql_fetch_array($query);

--

——

Was having trouble with this, forgot to exclude $

遇到了这个问题,忘了排除 $

回答by George Cummins

The problem is here:

问题在这里:

$query = $mysql_query("SELECT * FROM asd WHERE ID=$img1");

and here:

和这里:

$query = $mysql_query("SELECT * FROM asd WHERE ID=$img2");

Remove the '$' before mysql_query(...);

删除之前的'$' mysql_query(...);

回答by think1712

You are referencing mysql_query as a variable by prefixing it with the '$'. try removing the dollar to call the mysql_query function.

您将 mysql_query 作为变量引用,方法是在它前面加上“$”。尝试移除美元以调用 mysql_query 函数。