开发者

Unknown column 'value2' in 'field list'

I am recieving an error in my Codeigniter Model which is inserting a single row in a MySQL table. Here is a description of the error

A Database Error Occurred

Error Number: 1054

Unknown column 'value2' in 'field list'

INSERT INTO `tablename` (`column1`, `column2`) VALUES (value1, value2)

Filename: path\to\DB_driver.php

Line Number: 330

Both the columns are varchar columns.Does anyone know of this error?

The error message is verbatim copy pasted. My Controller code is as follows:

$deviceID=$xmlString->deviceID;
$appType=$xmlString->appType;
$data = array( 'deviceIdentifier' => $deviceID, 'installType'=>$appType );
$this->device_model->insert_new_device($data);

My model code is as follows

class device_model extends CI_Model {
    function insert_new_device($lDat开发者_JAVA百科a) { 
        $this->db->insert('devices', $lData);
        return $this->db->insert_id();
    } 
}


Based on the error reported by MySQL: value1 and value2 should be within single quotes as 'value1' and 'value2'.

UPDATE: The reason there are no quotes around the values in the query seems to be because the values that are being pulled from the XML are not exactly strings. Typecasting the results to string should ensure that the query parser quotes the values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜