A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list (/showthread.php?tid=67387) |
A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list - raminderrandhawa - 02-16-2017 I am getting the following error while adding the values to database . Though the values are being added in the database but the page with the errors shows up. A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: database/DB_driver.php Line Number: 1476 Backtrace: File: /var/www/inorasrs4/srs4code/application/models/Logger_model.php Line: 8 Function: insert File: /var/www/inorasrs4/srs4code/application/controllers/Calibration.php Line: 47 Function: write File: /var/www/inorasrs4/srs4code/application/controllers/Calibration.php Line: 250 Function: add File: /var/www/inorasrs4/srs4code/index.php Line: 315 Function: require_once Error Number: 1054 Unknown column 'Array' in 'field list' INSERT INTO `logs` (`message`, `action`, `username`) VALUES (Array, 'Add Calibration', 'srs4') Filename: models/Logger_model.php Line Number: 8 Could anyone help meĀ in eliminating this error. Thanks in anticipation. RE: A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list - spjonez - 02-16-2017 Whatever variable you're using as 'message' is an array not a string. RE: A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list - Wouter60 - 02-16-2017 It would help a lot if you share the code in your model (the function that is responsible for storing this data). Also share the code in your controller which is calling the model function. And please, use the php button on the button bar to create a php code block. Don't just paste code as plain text. RE: A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list - raminderrandhawa - 02-17-2017 I got it fixed as earlier it was adding array to the database which was causing the problem where $data is array. Earlier the code was if($msg=$this->Calibration_model->add_calibration($data)) { $this->load->model('Logger_model'); $this->Logger_model->write($this->session->userdata('username'),"Add Calibration",$msg); But now I have changed the code to add string instaed of array if($msg=$this->Calibration_model->add_calibration($data)) { $this->load->model('Logger_model'); $this->Logger_model->write($this->session->userdata('username'),"Add Calibration",$msg['msg']); Now, its working fine . Thanks for your help. RE: A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list - InsiteFX - 02-17-2017 You could have just serialized it and then unserialize it when needed. |