Mysql – Fix PHP error Invalid argument supplied for foreach() after update PHP & Mysql

mod-fcgidMySQLphp5

I have updated PHP from 5.3 version to PHP 5.6.21 (mod_fcgid) on my CentOs 6.5 vps.

The vps holds 4 Prestashop and almost works but cart doesn't work as expected.

The php error log contains this error:

mod_fcgid: stderr: PHP Warning:  Invalid argument supplied for foreach() in Cart.php

The failure is global in all sites hosted.

I have examined the file called Cart.php from Prestashop and the trouble is the foreach line.

$result = Db::getInstance()->ExecuteS('Large Query')
$productsIds = array();
$paIds = array();
foreach ($result as $row)
...

I don't see any error here, so I am searching what is wrong. I suppose the error after PHP update is related with new type restrictions or some misconfigured setting.

Need a hand, Thanks.

Best Answer

Solved.

The issue was related to database Mysql 5.7 when update from Msyql 5.1.

The error

mod_fcgid: stderr: PHP Warning:  Invalid argument supplied for foreach() in...

was right. The query executed by prestashop returned anything. Need to change

SQL mode in my.cnf to

sql-mode=TRADITIONAL
Related Topic