gpt4 book ai didi

mysql - 1064 : You have an error in your SQL syntax near ''

转载 作者:行者123 更新时间:2023-11-30 22:59:38 31 4
gpt4 key购买 nike

1064: 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 '' at line 4
SELECT a.* FROM ws_items a WHERE 1 AND enabled=1 AND visible=1 ORDER BY created DESC LIMIT 0,

我搜索了该网站,但没有一个符合我的查询。我不知道如何使用 mysql,但我真的需要解决这个问题...... 也许这里有人知道解决方案

 if ($params["page_name"]=="index")
{

$filter = "";
if ($_SESSION['user_data']['type']!="admin")
{
$filter = " AND `enabled`=1 AND `visible`=1 ";
}

$sql = "SELECT a.* FROM
`".DB_PREFIX."items` a WHERE 1 $filter
ORDER BY `created` DESC
LIMIT ".($_SESSION['itemsPerPage']*($page-1)).",".$_SESSION['itemsPerPage'];

$items = $DB->getAll($sql);
for($i=0; $i<count($items); $i++)
{
$items[$i][third] = "";

$items[$i][thumb_rating] = rating_bar($items[$i]['id'], '5', 'static');
if($i%3==2)
$items[$i][third] = 'style="margin-right:0;"';
}

$smarty->assign("items", $items);

$sql = "SELECT COUNT(a.id) as `total` FROM
`".DB_PREFIX."items` a WHERE 1 $filter
";

$items = $DB->get($sql);
$total = $items['total'];

$smarty->assign("pagination", $DB->show_pagination($total, $page, $_SESSION['itemsPerPage']));

$output = $this->display(__FILE__, 'latestwallpapers.tpl');
}
return $output;
}

最佳答案

我认为正在发生的事情是

$_SESSION['itemsPerPage']

为 null,当乘以 $page - 1 时,它被转换为 0,因此它在查询中的计算结果为 0,但在最后连接时什么也没有产生,这会导致语法错误在 LIMIT 子句中:

DESC LIMIT 0,

关于mysql - 1064 : You have an error in your SQL syntax near '' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24664024/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com