【问题标题】:Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL for the right syntax to use near [closed]错误号:1064 您的 SQL 语法有错误;检查与您的 MySQL 相对应的手册,以了解在 [关闭] 附近使用的正确语法
【发布时间】:2014-06-16 06:03:12
【问题描述】:

实际上,我在 HMVC 中使用 jquery 数据表。当我在数据表的搜索栏中写字符时,它给了我错误,就像我写'foo'它会给我

错误号:1064

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在 'LIKE '%foo%' OR uid LIKE '%foo%' OR pwd LIKE '%foo%' OR pooling LIKE '%foo%' OR ' 附近使用的正确语法在第 3 行

我的查询:

 public function data_loc_table()

     {
       $this->load->helper('datatables');            
       $this->datatables->select('data_location_id,group_name,provider,driver,server,port,protocol,database,uid,pwd,pooling,min_pool_size,max_pool_size,conn_reset,conn_life_time,modified_time,status')

            ->unset_column('data_location_id')
            ->unset_column('status')
            ->add_column('Status','$1', 'get_connected_meters(status)')
            ->add_column('Actions', get_dloc_buttons('$1'), 'data_location_id')
            ->from('data_location');
            return ;
        }

说明: 请帮我看看为什么会出现这个错误?

【问题讨论】:

  • 什么框架?也许您需要传递的不是字符串,而是多个字符串或数组到->select
  • 我不确定 return 没有定义 return ;
  • 它的 codeigniter 框架。亲爱的 Rangith,当我在数据表的搜索栏中输入一些字符时,我正在使用数据表,然后它给了我错误,就像我提到的那样
  • 当我在搜索栏中输入“foo”以从数据表中搜索时,它给了我这样的错误:
  • 您的 SQL 语法有误;检查与您的 MySQL 服务器版本相对应的手册,以获取在 'LIKE '%foo%' OR uid LIKE '%foo%' OR pwd LIKE '%foo%' OR pooling LIKE '%foo%' OR ' 附近使用的正确语法在第 3 行

标签: php mysql datatable


【解决方案1】:

我认为问题在于

'$1'

我们不能在单引号('')中使用php变量,所以尝试用双引号(“”)替换这些单引号

替换

'$1'

“$1”

【讨论】:

  • 对不起,DWX 但它不工作!
  • 好吧,它在 "$this->datatables->select('data_location_id,group_name,provider,driver,server,port,protocol,database,uid,pwd 中的 "uid" 之前给出错误,pooling,min_pool_size,max_pool_size,conn_reset,conn_life_time,modified_time,status')" 您不能像在 uid 之前使用的那样使用预定义的关键字或函数,如“数据库”。所以尝试从 $this->datatables->select(); 中删除“数据库”;
  • 非常感谢!! DWX 你真是太棒了!! -:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-30
  • 2014-08-17
  • 1970-01-01
  • 1970-01-01
  • 2017-02-14
  • 1970-01-01
  • 2022-01-24
相关资源
最近更新 更多