Category Archives: CodeIgniter

Codeigniter – The each() function is deprecated. This message will be suppressed on further calls

This is in fact an PHP 7.3 upgrade compatibility with older PHP scripts.
This is a quick fix for CodeIgniter.

Message: The each() function is deprecated. This message will be suppressed on further calls
Filename: core/Security.php | Line: 272

Quick fix
On line 272, of file application/system/core/Security.php there should be an ‘while’ with a ‘each’.
Make the following changes

        //while (list($key) = each($str))
        foreach($str as $key=>$str_values)

Your server does not support the GD function required to process this type of image.

This is how I’v solved this issue, in a loop….

FROM

$this->load->library('image_lib', $resize_config);
if ( ! $this->image_lib->resize() )
{
    echo $this->image_lib->display_errors();
    exit();
}
$this->image_lib->clear();

TO

$this->load->library('image_lib');
$this->image_lib->initialize($resize_config);
if ( ! $this->image_lib->resize() )
{
    echo $this->image_lib->display_errors();
    exit();
}
$this->image_lib->clear();

codeigniter + php + mysql – emojis 😉

This is how…

On mysql set your table(s)’s filed(s) to utf8mb4_general_ci.

codeigniter config/database.php
$db['default']['char_set'] = 'utf8mb4';
$db['default']['dbcollat'] = 'utf8mb4_general_ci';
Resources

https://stackoverflow.com/questions/10957238/incorrect-string-value-when-trying-to-insert-utf-8-into-mysql-via-jdbc

https://stackoverflow.com/questions/16828197/displaying-utf8-character-on-codeigniter

500 Internal Server Error while uploading files

I was having a 500 Internal Server Error…
nginx logs were showing me the following

2016/03/17 12:09:32 [crit] 31488#0: *11192 open() "/var/lib/nginx/tmp/client_body/0000000005" failed (13: Permission denied), client: 84.91.XXX.XXX, server: host.com, request: "POST /trades_edit/edit_trade HTTP/1.1", host: "host.com", referrer: "https://host.com/trades_edit/125"

Solution?

chown -R www-data:www-data /var/lib/nginx

Codeigniter – Message: Only variable references should be returned by reference

On a new deployment of a Codeigniter tool that I’v made, I got the following error, after installed it in more than 10 different servers… my own servers and clients…

Severity: Notice

Message: Only variable references should be returned by reference

Filename: core/Common.php

Line Number: 257

 

This only happens with PHP >= 5.6….

We need to tweak /system/core/Common.php Line number 257
Change this line from

return $_config[0] =& $config;

to

$_config[0] =& $config;
return $_config[0];

“MySQL server has gone away” with CodeIgniter and MySQL

I’v stopped using CodeIgniter for 7 months, but I maintaining a product that was developed under CI.

rock ssd

Today I’v got a error saying  “MySQL server has gone away” after a long time PHP execution.
I’v managed to solve it by, on the model that was getting me the error, *reconnect* to the database .

Before the *command* i’v added $this->db->reconnect();

 $this->db->reconnect();
 $this->db->insert('photoGallery', $data);
 return $this->db->insert_id();

Hope it helps anyone out there.