• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list

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


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.

Whatever variable you're using as 'message' is an array not a string.

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.

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->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->Logger_model->write($this->session->userdata('username'),"Add Calibration",$msg['msg']);

Now, its working fine . Thanks for your help.

You could have just serialized it and then unserialize it when needed.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.