开发者

parse error in eval() - eval()'d code [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

Where is the problem in my eval code??? because Apache said:

Parse error: syntax error, unexpected T_STRING in E:\xa开发者_如何学JAVAmpp\htdocs\1php\mas_res\inc\mysql_class.php(120) : eval()'d code on line 1

my code:

            $type1 = "row";
            $query1 = mysql_query("SELECT * FROM table");
            $textToEval = "mysql_fetch_{$type1}($query1);";
            $query = eval($textToEval);

And what is the correct mode??

Thanks ..


Don't use eval! Use PHP's variable functions:

$function = 'mysql_fetch_' . $type1;
$query = $function($query1);

Oh, and if you want to know, what was the fault: You forgot to escape the $ in $query1. It should be \$query1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜