CodeIgniter Forums
Array to string conversion - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Array to string conversion (/showthread.php?tid=61247)



Array to string conversion - vertisan - 04-04-2015

Hi!

I have little problem with my script. I getting error:
PHP Code:
SeverityNotice

Message
: Array to string conversion

Filename
V_panel/wydarzenia.php

Line Number
56 

Here is full script:
PHP Code:
function pobierz_wpisy_kalendarza$rok$miesiac )
 {
 
 
$query $this->db->select'date''data' )
 
 ->from'kalendarz' )
 
 ->like'date'"$rok-$miesiac"'after' )
 
 ->get();

 
$wpisy = array();

 foreach ( 
$query->result() as $row ) {
 
$wpisy[substr($row->date,8,2)] = $row->data;
 }

 return 
$wpisy;

 } 

This is bad line:
PHP Code:
<?php echo $wpisy?>
so this is only echo for variable, so something is wrong in model (UP).


RE: Array to string conversion - sv3tli0 - 04-04-2015

PHP basics you CAN'T echo array...
Use print_r($wispy); instead..


RE: Array to string conversion - vertisan - 04-04-2015

So i getting now:
PHP Code:
Array ( ) 



RE: Array to string conversion - sv3tli0 - 04-04-2015

It seems that there are no results to your query.

Log your query with $this->db->last_query();
you can add it to $wispy['query']= $this->db->last_query(); After you have runned the select..

And see what is the generated query ..


RE: Array to string conversion - ivantcholakov - 04-04-2015

... $this->db->select( 'date, data' ) ...