- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
an error in your SQL syntax"-6ren"> an error in your SQL syntax"-我正在使用 Joomla 模块 (ArogaRousel),该模块是用来显示另一个模块 (AdsManager) 的图像,并且该模块显示以下错误: No valid database connecti-6ren">
我正在使用 Joomla 模块 (ArogaRousel),该模块是用来显示另一个模块 (AdsManager) 的图像,并且该模块显示以下错误:
No valid database connection 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 ')) ORDER BY views DESC, id LIMIT 0, 9' at line 1 SQL=SELECT *,concat('/images/com_adsmanager/ads/',id,'a.jpg') as imgUrl FROM root_adsmanager_ads , root_adsmanager_adcat as ac WHERE published=1 AND (ac.adid=id and ac.catid IN ()) ORDER BY views DESC, id LIMIT 0, 9
我不精通mysql,但是我找到了进行查询的文件。
这是进行查询的代码
$query = "SELECT *,concat('/images/com_adsmanager/ads/',id,'a.jpg') as imgUrl FROM #__adsmanager_ads "
. $table
. " WHERE published=1 "
. $where
. $ordering
. $limit;
各位有识之士能否指出错误和解决方案?
为了回应 Bemace,我在这里添加了整个函数
// Get list of banners
function getAds(&$paramslist){
$where = array();
if ($paramslist['ads'] != '') $where[] = 'id IN (' . modArogarouselAdsmanagerHelper::cleanIds($paramslist['ads']) . ')';
if ($paramslist['categories'] != '') {
$where[] = 'ac.adid=id and ac.catid IN (' . modArogarouselAdsmanagerHelper::cleanIds($paramslist['categories']) . ')';
$table = ' , #__adsmanager_adcat as ac';
}
$where = (count($where) > 0) ? ' AND (' . implode(' OR ', $where) . ')' : '';
if ($paramslist['ordering'] == 1) {
$ordering = ' ORDER BY views DESC, id';
} else if ($paramslist['ordering'] == 2) {
$ordering = ' ORDER BY views ASC';
} else if ($paramslist['ordering'] == 3) {
$ordering = ' ORDER BY id';
} else if ($paramslist['ordering'] == 4) {
$ordering = ' ORDER BY RAND()';
}
$limit = ($paramslist['limit'] != '') ? ' LIMIT 0, ' . ($paramslist['limit']) : '';
$query = "SELECT *,concat('/images/com_adsmanager/ads/',id,'a.jpg') as imgUrl FROM #__adsmanager_ads "
. $table
. " WHERE published=1 "
. $where
. $ordering
. $limit;
$db = &JFactory::getDBO();
$db->setQuery($query);
$adslist = $db->loadObjectList();
$adslist = ($paramslist['mode_dir'] == 'bottom') ? array_reverse($adslist, true) : $adslist;
//print_r($adslist);
return $adslist;
}
最佳答案
ORDER BY
之前的空 IN ()
就是问题所在。您需要检查设置 $where
变量的代码。它似乎期望至少选择一个类别,但似乎没有选择。
关于mysql - 使用 Joomla 模块并收到错误 "No valid database connection You have > an error in your SQL syntax",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4446512/
我是一名优秀的程序员,十分优秀!