搜索
首页后端开发php教程destoon复制模块是出现的mysql报错,求大神解决

MySQL Query:SELECT * FROM [pre]vipcenter_25 WHERE status=3 ORDER BY LIMIT 0,20 
MySQL Error: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 'LIMIT 0,20' at line 1 MySQL Errno:0 
Message:MySQL Query Error



我想在公司主页上添加一个“成功案例”的新模块,复制的“品牌展示”的模块,把代码中的brand批量替换成success,其他都没问题就是在后台模块编辑时候出现这个报错


回复讨论(解决方案)

SELECT * FROM [pre]vipcenter_25 WHERE status=3 ORDER BY LIMIT 0,20 
检查下sql,是否可以执行。

ORDER BY  XX LIMIT 0,20 

不能执行,,

SELECT * FROM [pre]vipcenter_25 WHERE status=3  ORDER BY LIMIT 0,20 
多了套红的部分,如何你能运行?

SELECT * FROM [pre]vipcenter_25  也报错

SQL] SELECT * FROM [pre]vipcenter_25

[Err] 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 '[pre]vipcenter_25' at line 1

SQL] SELECT * FROM [pre]vipcenter_25

[Err] 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 '[pre]vipcenter_25' at line 1


确定你表的名称书写正确,还有order by  xx    xx必须为表的字段属性,你上面未加上。

我试了,加上了也不行啊


SQL] SELECT * FROM [pre]vipcenter_25

[Err] 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 '[pre]vipcenter_25' at line 1


确定你表的名称书写正确,还有order by  xx    xx必须为表的字段属性,你上面未加上。
are you sure?

其实我也不太懂,我是个新手,但是我是完全复制的原有的模块的代码,数据库也新建了表,不知道是哪里出了问题

其实我也不太懂,我是个新手,但是我是完全复制的原有的模块的代码,数据库也新建了表,不知道是哪里出了问题



确定你表的名称书写正确,还有order by xx    xx必须为表的字段属性,你上面未加上。
1.select * from tablename?
2.select * from tablename order by id?

function get_list($condition = 'status=3', $order = 'edittime DESC', $cache = '') {
global $MOD, $pages, $page, $pagesize, $offset, $items, $sum;
if($page > 1 && $sum) {
$items = $sum;
} else {
$r = $this->db->get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition", $cache);
$items = $r['num'];
}
$pages = defined('CATID') ? listpages(1, CATID, $items, $page, $pagesize, 10, $MOD['linkurl']) : pages($items, $page, $pagesize);
$lists = $catids = $CATS = array();
$result = $this->db->query(" SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize", $cache);
while($r = $this->db->fetch_array($result)) {
$r['adddate'] = timetodate($r['addtime'], 5);
$r['editdate'] = timetodate($r['edittime'], 5);
$r['todate'] = timetodate($r['totime'], 3);
$r['alt'] = $r['title'];
$r['title'] = set_style($r['title'], $r['style']);
$r['linkurl'] = $MOD['linkurl'].$r['linkurl'];
$catids[$r['catid']] = $r['catid'];
$lists[] = $r;
}

SELECT * FROM  destoon_vipcenter_25 WHERE status=3 ORDER BY  edittime LIMIT 0,20  可以查询

输出看看:
die("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
检查{$this->table},$condition,$order , $offset, $pagesize,对应是否有值

SELECT * FROM [pre]vipcenter_25  也报错


表名字怎么会出现这个?

输出看看:
die("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize");
检查{$this->table},$condition,$order , $offset, $pagesize,对应是否有值




什么都没输出,没有值


SELECT * FROM [pre]vipcenter_25  也报错


表名字怎么会出现这个?

这个我也不清楚,以前没学过php

源代码:

echo  "SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize";
die();

再试试

defined('IN_DESTOON') or exit('Access Denied');
class vipcenter {
var $moduleid;
var $itemid;
var $db;
var $table;
var $table_data;
var $split;
var $fields;
var $errmsg = errmsg;
var $pre;

    function vipcenter($moduleid) {
global $db, $table, $table_data, $MOD;
$this->moduleid = $moduleid;
$this->table = $table;
$this->table_data = $table_data;
$this->split = $MOD['split'];
$this->db = &$db;
$this->pre = $this->db->pre;
$this->fields = array('catid','level','title','style','fee','introduce','areaid','thumb','homepage','status','hits','username','addtime','adddate','editor','edittime','editdate','ip','template', 'linkurl','filepath','note','company','truename','telephone','mobile','address','email','msn','qq','ali','skype');
    }

function pass($post) {
global $DT_TIME, $MOD;
if(!is_array($post)) return false;
if(!$post['catid']) return $this->_(lang('message->pass_catid'));
if(strlen($post['title']) _(lang('message->pass_title'));
if(!$post['thumb']) return $this->_(lang('message->pass_logo'));
return true;
}

function set($post) {
global $MOD, $DT_TIME, $DT_IP, $_username, $_userid;
$post['editor'] = $_username;
$post['addtime'] = (isset($post['addtime']) && $post['addtime']) ? strtotime($post['addtime']) : $DT_TIME;
$post['adddate'] = timetodate($post['addtime'], 3);
$post['edittime'] = $DT_TIME;
$post['editdate'] = timetodate($post['edittime'], 3);
$post['fee'] = dround($post['fee']);
$post['homepage'] = fix_link(trim($post['homepage']));
$post['video'] = fix_link(trim($post['video']));
$post['video_width'] = intval($post['video_width']);
$post['video_height'] = intval($post['video_height']);
$post['title'] = trim($post['title']);
$post['content'] = stripslashes($post['content']);
$post['content'] = save_local($post['content']);
if($MOD['clear_link']) $post['content'] = clear_link($post['content']);
if($MOD['save_remotepic']) $post['content'] = save_remote($post['content']);
if($MOD['introduce_length']) $post['introduce'] = addslashes(get_intro($post['content'], $MOD['introduce_length']));
if($this->itemid) {
$new = $post['content'];
if($post['thumb']) $new .= 'destoon复制模块是出现的mysql报错,求大神解决';
$r = $this->get_one();
$old = $r['content'];
if($r['thumb']) $old .= 'destoon复制模块是出现的mysql报错,求大神解决';
delete_diff($new, $old);
} else {
$post['ip'] = $DT_IP;
}
if(!defined('DT_ADMIN')) {
$content = $post['content'];
unset($post['content']);
$post = dhtmlspecialchars($post);
$post['content'] = dsafe($content);
}
$post['content'] = addslashes($post['content']);
return array_map("trim", $post);
}

function get_one() {
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
        return $this->db->get_one("SELECT * FROM {$this->table} a,{$content_table} c WHERE a.itemid=c.itemid and a.itemid=$this->itemid");
}

function get_list($condition = 'status=3', $order = 'edittime DESC', $cache = '') {
global $MOD, $pages, $page, $pagesize, $offset, $items, $sum;
if($page > 1 && $sum) {
$items = $sum;
} else {
$r = $this->db->get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition", $cache);
$items = $r['num'];
}
$pages = defined('CATID') ? listpages(1, CATID, $items, $page, $pagesize, 10, $MOD['linkurl']) : pages($items, $page, $pagesize);
$lists = $catids = $CATS = array();

$result = $this->db->query("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize", $cache);

while($r = $this->db->fetch_array($result)) {
$r['adddate'] = timetodate($r['addtime'], 5);
$r['editdate'] = timetodate($r['edittime'], 5);
$r['todate'] = timetodate($r['totime'], 3);
$r['alt'] = $r['title'];
$r['title'] = set_style($r['title'], $r['style']);
$r['linkurl'] = $MOD['linkurl'].$r['linkurl'];
$catids[$r['catid']] = $r['catid'];
$lists[] = $r;
}
if($catids) {
$result = $this->db->query("SELECT catid,catname,linkurl FROM {$this->db->pre}category WHERE catid IN (".implode(',', $catids).")");
while($r = $this->db->fetch_array($result)) {
$CATS[$r['catid']] = $r;
}
if($CATS) {
foreach($lists as $k=>$v) {
$lists[$k]['catname'] = $v['catid'] ? $CATS[$v['catid']]['catname'] : '';
$lists[$k]['caturl'] = $v['catid'] ? $MOD['linkurl'].$CATS[$v['catid']]['linkurl'] : '';
}
}
}
return $lists;
}

function add($post) {
global $MOD;
$post = $this->set($post);
$sqlk = $sqlv = '';
foreach($post as $k=>$v) {
if(in_array($k, $this->fields)) { $sqlk .= ','.$k; $sqlv .= ",'$v'"; }
}
        $sqlk = substr($sqlk, 1);
        $sqlv = substr($sqlv, 1);
$this->db->query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
$this->itemid = $this->db->insert_id();
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
$this->db->query("INSERT INTO {$content_table} (itemid,content) VALUES ('$this->itemid', '$post[content]')");
$this->update($this->itemid);
if($post['status'] == 3 && $post['username'] && $MOD['credit_add']) {
credit_add($post['username'], $MOD['credit_add']);
credit_record($post['username'], $MOD['credit_add'], 'system', lang('my->credit_record_add', array($MOD['name'])), 'ID:'.$this->itemid);
}
clear_upload($post['content'].$post['thumb'], $this->itemid);
return $this->itemid;
}

function edit($post) {
$this->delete($this->itemid, false);
$post = $this->set($post);
$sql = '';
foreach($post as $k=>$v) {
if(in_array($k, $this->fields)) $sql .= ",$k='$v'";
}
        $sql = substr($sql, 1);
    $this->db->query("UPDATE {$this->table} SET $sql WHERE itemid=$this->itemid");
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
    $this->db->query("UPDATE {$content_table} SET content='$post[content]' WHERE itemid=$this->itemid");
$this->update($this->itemid);
clear_upload($post['content'].$post['thumb'], $this->itemid);
if($post['status'] > 2) $this->tohtml($this->itemid, $post['catid']);
return true;
}

function tohtml($itemid = 0, $catid = 0) {
global $module, $MOD;
if($MOD['show_html'] && $itemid) tohtml('show', $module, "itemid=$itemid");
}

function update($itemid) {
$item = $this->db->get_one("SELECT * FROM {$this->table} WHERE itemid=$itemid");
$update = '';
$keyword = $item['title'].','.$item['company'].','.strip_tags(cat_pos(get_cat($item['catid']), ',')).strip_tags(area_pos($item['areaid'], ','));
if($keyword != $item['keyword']) {
$keyword = str_replace("//", '', addslashes($keyword));
$update .= ",keyword='$keyword'";
}
$item['itemid'] = $itemid;
$linkurl = itemurl($item);
if($linkurl != $item['linkurl']) $update .= ",linkurl='$linkurl'";
$member = $item['username'] ? userinfo($item['username']) : array();
if($member) {
foreach(array('groupid','vip','validated','company','areaid','truename','telephone','mobile','address','qq','msn','ali','skype') as $v) {
if($item[$v] != $member[$v]) $update .= ",$v='".addslashes($member[$v])."'";
}
if($item['email'] != $member['mail']) $update .= ",email='".addslashes($member['mail'])."'";
}
if($update) $this->db->query("UPDATE {$this->table} SET ".(substr($update, 1))." WHERE itemid=$itemid");
}

function recycle($itemid) {
if(is_array($itemid)) {
foreach($itemid as $v) { $this->recycle($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=0 WHERE itemid=$itemid");
$this->delete($itemid, false);
return true;
}
}

 

function restore($itemid) {
global $module, $MOD;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->restore($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=3 WHERE itemid=$itemid");
if($MOD['show_html']) tohtml('show', $module, "itemid=$itemid");
return true;
}
}

function delete($itemid, $all = true) {
global $MOD;
if(is_array($itemid)) {
foreach($itemid as $v) { 
$this->delete($v, $all);
}
} else {
$this->itemid = $itemid;
$r = $this->get_one();
if($MOD['show_html']) {
$_file = DT_ROOT.'/'.$MOD['moduledir'].'/'.$r['linkurl'];
if(is_file($_file)) unlink($_file);
}
if($all) {
$userid = get_user($r['username']);
if($r['thumb']) delete_upload($r['thumb'], $userid);
if($r['content']) delete_local($r['content'], $userid);
$this->db->query("DELETE FROM {$this->table} WHERE itemid=$itemid");
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
$this->db->query("DELETE FROM {$content_table} WHERE itemid=$itemid");
if($MOD['cat_property']) $this->db->query("DELETE FROM {$this->db->pre}category_value WHERE moduleid=$this->moduleid AND itemid=$itemid");
if($r['username'] && $MOD['credit_del']) {
credit_add($r['username'], -$MOD['credit_del']);
credit_record($r['username'], -$MOD['credit_del'], 'system', lang('my->credit_record_del', array($MOD['name'])), 'ID:'.$this->itemid);
}
}
}
}

function check($itemid) {
global $_username, $DT_TIME, $MOD;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->check($v); }
} else {
$this->itemid = $itemid;
$item = $this->get_one();
if($MOD['credit_add'] && $item['username'] && $item['hits']  credit_add($item['username'], $MOD['credit_add']);
credit_record($item['username'], $MOD['credit_add'], 'system', lang('my->credit_record_add', array($MOD['name'])), 'ID:'.$this->itemid);
}
$editdate = timetodate($DT_TIME, 3);
$this->db->query("UPDATE {$this->table} SET status=3,hits=hits+1,editor='$_username',edittime=$DT_TIME,editdate='$editdate' WHERE itemid=$itemid");
$this->tohtml($itemid);
return true;
}
}

function reject($itemid) {
global $_username, $DT_TIME;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->reject($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=1,editor='$_username' WHERE itemid=$itemid");
return true;
}
}

function clear($condition = 'status=0') {
$result = $this->db->query("SELECT itemid FROM {$this->table} WHERE $condition ");
while($r = $this->db->fetch_array($result)) {
$this->delete($r['itemid']);
}
}

function level($itemid, $level) {
$itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
$this->db->query("UPDATE {$this->table} SET level=$level WHERE itemid IN ($itemids)");
}

function refresh($itemid) {
global $DT_TIME;
$editdate = timetodate($DT_TIME, 3);
$itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
$this->db->query("UPDATE {$this->table} SET edittime='$DT_TIME',editdate='$editdate' WHERE itemid IN ($itemids)");
}

function _($e) {
$this->errmsg = $e;
return false;
}
}

?>

 

输出:SELECT * FROM destoon_vipcenter_25 WHERE status=3 ORDER BY LIMIT 0,20

echo  "SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize";
die();

再试试


你还是针对这个问题,贴出输出结果吧,不然你问的问题,没办法解答了。

问题算是解决了,function get_list($condition = 'status=3',  $order = 'edittime DESC', $cache = '') {
global $MOD, $pages, $page, $pagesize, $offset, $items, $sum;
if($page > 1 && $sum) {
$items = $sum;
} else {
$r = $this->db->get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition", $cache);
$items = $r['num'];
}
$pages = defined('CATID') ? listpages(1, CATID, $items, $page, $pagesize, 10, $MOD['linkurl']) : pages($items, $page, $pagesize);
$lists = $catids = $CATS = array();

$result = $this->db->query("SELECT * FROM {$this->table} WHERE $condition ORDER BY  $order LIMIT $offset,$pagesize", $cache);



是获得不了$order的值,直接用edittime DESC代替$order,运行没问题。但是现在不明白是为什么获得不了$order的值


echo  "SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize";
die();

再试试


你还是针对这个问题,贴出输出结果吧,不然你问的问题,没办法解答了。



还是非常感谢你!

这个问题我告诉你原因吧,你复制了模块之后 没对模块进行设置  点击菜单最下面 模块设置 设置一下模块就好了。 这绝对是正确答案 你不要着急去改代码  代码没有问题的  。

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
golang 报错:“unexpected end of JSON input” 如何解决?golang 报错:“unexpected end of JSON input” 如何解决?Jun 24, 2023 pm 09:52 PM

近年来,Google开发并推出的go语言(也称为golang)已经成为许多开发者的选择之一。Golang以其快速的编译速度、高效的内存管理和强大的网络编程能力而被广泛应用。但在开发中,我们可能会遇到各种问题,例如在使用JSON解析库时,可能会遇到“unexpectedendofJSONinput”这个错误。什么是“unexpectedendof

golang 报错:“possible misuse of unsafe.Pointer” 如何解决?golang 报错:“possible misuse of unsafe.Pointer” 如何解决?Jun 24, 2023 pm 04:38 PM

在使用golang过程中,由于一些原因导致程序出现报错,其中一个常见的错误是“possiblemisuseofunsafe.Pointer”。本文将会详细介绍这个错误的含义与解决方法。一、错误含义在golang中,unsafe.Pointer是一个特殊的指针类型,用于表示任意类型的指针,并且可以进行指针的相互转换,这为我们提供了更高的灵活性和扩展性。但

golang 报错:“undeclared name…” 如何解决?golang 报错:“undeclared name…” 如何解决?Jun 24, 2023 pm 03:31 PM

Golang(Go编程语言)是一种基于C语言的编程语言,被广泛用于Web开发、网络编程、操作系统等领域。然而,在编写Golang程序时经常会遇到一个常见的问题,就是“undeclaredname”(未声明名称)错误。下面将介绍如何解决这个问题。了解错误信息在编译和运行Golang程序时,如果遇到了未声明名称错误,会在控制台输出相应的错误信

golang 报错:“invalid use of … operator” 如何解决?golang 报错:“invalid use of … operator” 如何解决?Jun 24, 2023 pm 05:54 PM

对于Golang开发者来说,“invaliduseof…operator”是一个常见的报错。这个报错通常会在使用变长参数函数时出现。它在编译时就会被检测出来,并指出哪些部分有问题。这篇文章将介绍如何解决这个报错。一、什么是变长参数函数变长参数函数也被称为可变参数函数,是Golang语言中的一种函数类型。使用变长参数函数可以像如下方式定义多个

解决Python报错:IndexError: list index out of range解决Python报错:IndexError: list index out of rangeAug 17, 2023 am 09:21 AM

解决Python报错:IndexError:listindexoutofrange在编写Python程序时经常会遇到各种报错,其中一种常见的错误是"IndexError:listindexoutofrange"。这个错误通常意味着你尝试访问一个列表中不存在的索引。在本文中,我将会解释该错误的原因,并给出几种可能的解决方案。首先,让我们看一

解决PHP报错:未定义属性访问权限的问题解决PHP报错:未定义属性访问权限的问题Aug 17, 2023 am 08:19 AM

解决PHP报错:未定义属性访问权限的问题在使用PHP进行开发过程中,我们经常会遇到报错的情况。其中一个常见的报错是“未定义属性访问权限”。这个报错一般是指在访问一个类对象的属性时,该属性没有被定义或者没有设置访问权限。本文将针对这个问题进行分析,并给出解决方案。首先,我们需要了解一下PHP中的属性访问权限。在PHP中,属性可以被设置为public、prote

PHP报错:无法连接数据库的解决方法PHP报错:无法连接数据库的解决方法Jul 12, 2023 pm 06:07 PM

PHP报错:无法连接数据库的解决方法在使用PHP开发过程中,经常会遇到无法连接数据库的问题。这是非常常见的错误,但是却给开发人员带来不小的困扰。本文将介绍一些常见的解决方法,并提供相应的代码示例,帮助开发人员快速解决该问题。检查数据库连接信息首先,应该检查数据库连接信息是否正确。通常,数据库连接信息包括主机名、用户名、密码和数据库名。正确无误的数据库连接信息

golang 报错:“missing return…” 如何解决?golang 报错:“missing return…” 如何解决?Jun 24, 2023 pm 04:37 PM

在golang中,函数在定义时需要明确返回值类型和返回值,但有时候会出现“missingreturn…”的错误,表示函数缺少返回语句。本文将介绍如何解决这个问题。确认函数签名如果在定义函数时声明了返回值类型,但没有返回具体的值,就会触发这个错误。因此,你可以先检查函数签名,确认声明了返回值类型。举个例子:funcadd(a,bint)int{

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境