2013-03-18 89 views
1

我這個錯誤,我跟這個代碼不等於笨活動記錄比較

$this->db->order_by('uid','DESC')->where('type!=',"Admin")->get('user_profile',$config['per_page'], $this->uri->segment(3)); 

這裏接收相當混亂是我得到的錯誤

Error Number: 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 ''Admin' ORDER BY `uid` DESC LIMIT 10' at line 3 

SELECT * FROM (`user_profile`) WHERE `type!=` 'Admin' ORDER BY `uid` DESC LIMIT 10 

Filename: C:\wamp\www\proposal\system\database\DB_driver.php 

Line Number: 330 
+0

嘗試把type'和'!=' – Jeemusu 2013-03-18 10:02:36

+0

對不起,谷歌和計算器研究之後,我找到了解決辦法之間'的空間。只有人必須在操作員和現場之間放置空間。在我的情況下$ this-> db-> where('type!=',「Admin」) – 2013-03-18 10:06:03

回答

5

試着像您查詢這個。管理員使用單個逗號而不是雙逗號。和>代替<!=

$this->db 
    ->where('type <>','Admin') 
    ->order_by('uid','DESC') 
    ->get('user_profile',$config['per_page'], $this->uri->segment(3)); 
+0

謝謝Raheel的幫助。它真的有效 – 2013-03-18 10:51:55

+0

快速提示:不要忘記字段名和「<>」之間的空格,應該是'type <>'而不是'type <>'。第二個將失敗。 – 2016-09-06 19:37:40