无法隐藏错误消息

时间:2014-03-07 11:56:17

标签: php

如何隐藏像这样的错误

You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near '\\\') as previousid,
(SELECT IFNULL(min(id),-1) FROM bikes WHERE' at line 2

我已将off放在display_errors = Offerror_reporting = E_ALL & ~E_NOTICE上 如果我在查询之前将error_reporting(0);置于我的代码或@之上,也无关紧要。始终显示错误。

编辑:

$q = mysqli_query($con, 'SELECT *,
            (SELECT IFNULL(max(id),-1) FROM bikes WHERE `id` < '.($currentId).') as previousid,
            (SELECT IFNULL(min(id),-1) FROM bikes WHERE `id` > '.($currentId).') as nextid
                FROM bikes WHERE `id` = ' . ($currentId)))

如果我尝试使用URL,请说bikes.php?id='或其他sql注入我在我的页面上得到这个。

查询工作正常,这是我尝试在URL中操作(sql注入)。然后它显示了这个,我想隐藏它。我不想为我的表格显示信息......等等。

1 个答案:

答案 0 :(得分:0)

您的错误似乎来自您的SQL查询。请尝试:

$q = mysqli_query($con, 'SELECT *,
            (SELECT IFNULL(max(id),-1) FROM `bikes` WHERE `id` < '.$currentId.') as previousid,
            (SELECT IFNULL(min(id),-1) FROM `bikes` WHERE `id` > '.$currentId.') as nextid
                FROM bikes WHERE `id` = ' . $currentId))