Welcome Guest, Not a member yet? Register   Sign In
A Database Error Occurred Error Number: 1054 Unknown column 'Array' in 'field list
#1

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.
Reply
#2

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

(This post was last modified: 02-16-2017, 01:54 PM by Wouter60.)

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.
Reply
#4

(This post was last modified: 02-17-2017, 06:59 AM by raminderrandhawa. Edit Reason: missed something )

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.
Reply
#5

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 )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB