解析错误:语法错误,意外的 T_IF
$query = "SELECT a.*, cc.name AS category, dd.ezcity AS proploc, ee.name AS statename, ff.name AS cnname, ss.dealer_name AS propseller, u.name AS editor"
. "\n FROM #__ezrealty AS a"
. "\n LEFT JOIN #__ezrealty_catg AS cc ON cc.id = a.cid"
. "\n LEFT JOIN #__ezrealty_locality AS dd ON dd.id = a.locid"
. "\n LEFT JOIN #__ezrealty_state AS ee ON ee.id = a.stid"
. "\n LEFT JOIN #__ezrealty_country AS ff ON ff.id = a.cnid"
. "\n LEFT JOIN #__ezrealty_profile AS ss ON ss.mid = a.owner"
. "\n LEFT JOIN #__users AS u ON u.id = a.checked_out"
. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "")
. if ( isset ($_POST['idSearch']) )
. { " WHERE a.id = " . $_POST['idSearch'] ; }
. "\n ORDER BY ". $order
. "\n LIMIT $pageNav->limitstart, $pageNav->limit"
;
我在这里没有得到错误的语法:(,,并且它不断返回相同的错误意外 T_IF
$query = "SELECT a.*, cc.name AS category, dd.ezcity AS proploc, ee.name AS statename, ff.name AS cnname, ss.dealer_name AS propseller, u.name AS editor"
. "\n FROM #__ezrealty AS a"
. "\n LEFT JOIN #__ezrealty_catg AS cc ON cc.id = a.cid"
. "\n LEFT JOIN #__ezrealty_locality AS dd ON dd.id = a.locid"
. "\n LEFT JOIN #__ezrealty_state AS ee ON ee.id = a.stid"
. "\n LEFT JOIN #__ezrealty_country AS ff ON ff.id = a.cnid"
. "\n LEFT JOIN #__ezrealty_profile AS ss ON ss.mid = a.owner"
. "\n LEFT JOIN #__users AS u ON u.id = a.checked_out"
. ( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "")
. if ( isset ($_POST['idSearch']) )
. { " WHERE a.id = " . $_POST['idSearch'] ; }
. "\n ORDER BY ". $order
. "\n LIMIT $pageNav->limitstart, $pageNav->limit"
;
i don get the wrong syntax here :( ,, and it keep return the same error unexpected T_IF
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
删除 . (点)在 if 语句之前。因为 if 语句本身不是字符串,所以您不能只是将其连接起来。
Remove the . (point) before the if-statement. Because the if-statement itself isn't a string you can't just concatenate it.
不要这样做:
而是这样做:
Don't do this:
Instead do this:
if
只能是一个语句:您将其用作 表达式。它不返回任何内容,并且不能在另一个语句中使用。但是,您可以使用三元运算符来执行此操作:
这表示“如果设置了
$_POST['idSearch']
,则添加该字符串,否则,添加空字符串。请注意,您应该仔细看看你的代码,因为我上面发布的代码中存在明显的 SQL 注入,任何人都可以在你的数据库上执行任意代码,并且最好采用准备好的语句和参数化查询。让你的代码更安全。
if
can only ever be a statement: you are using it as an expression. It doesn't return anything, and it cannot be used within another statement.You can, however, use the ternary operator to do exactly this:
This says "if
$_POST['idSearch']
is set, add that string, otherwise, add the empty string.Note that you should really look at your code, because there is a glaring SQL injection in just the code that I've posted above. Anyone could execute arbitrary code on your database. Make sure to sanitise your input and, preferably, adopt prepared statements and parameterised queries to make your code more secure.
我相信你想把它变成一个邪恶三元运算符:
I believe you want to turn this into an evil ternary operator: