-3 php mysql sql codeigniter
使用时:
$cols_string = implode(',',$cols_array;
$query = "INSERT INTO TB_BATs (col1, col2, col3 VALUES $cols_string "
$this->db->query($query);
Run Code Online (Sandbox Code Playgroud)
我明白了 "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 3 "
接下来是SQL查询,但是当我在PHPMYADMIN中复制查询时它工作正常,如果将其复制到$query字符串中它也可以正常工作,问题出现时才会使用$cols_string
你忘了关上括号
$query = "INSERT INTO TB_BATs (col1, col2, col3) VALUES ($cols_string)"
还在这里:
$cols_string = implode(',',$cols_array);