Invalid argument for foreach |
Hi,
I'm new in this forum and so i apologize if my message isn't fully respectfull of your traditions... Moreover, i'm not very good in english... so i'm sorry if i make errors in writting. I can't say if the bug i have in my application is fully linked to PHP 7.2 but i observe that i have problem when i configure my server in 7.2 and i have no problem when i configure my server in 7.1. My CodeIgniter is 3.1.5 version and this is error i have with PHP 7.2 : A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: controllers/Newsmanager.php Line Number: 127 Backtrace: File: /home/nbbeliar/public_html/ex/igniter/application/controllers/[b][i]Newsmanager.php[/i][/b] Line: 127 Function: _error_handler File: /home/nbbeliar/public_html/ex/igniter/index.php Line: 315 Function: require_once Here the PHP code : PHP Code: if ( ! $this->upload->do_upload('userfile')) I think it's an indirect error. Because with PHP 7.1, my upload succeed, so this section isn't started with 7.1 (the upload succeed) and i've understood that PHP Code: display_errors(); function don't have an array result but a string result... what explains the foreach error. But that doesn't explain the reason why upload works perfectly with PHP 7.1 and doesn't work anyway with PHP 7.2... My full original PHP code for this upload section... PHP Code: public function addnewssumbit() When i solve my error with $info = $this->upload->display_errors(); (using it as string and no as array... without for each), i have no one error message but... no one content into display_errors(); function despite the fact my upload failed ! So i think something is going wrong with upload with PHP 7.2... and CodeIgniter 3.1.5 ? But i don't know what. So, i've set back my server to PHP 7.1... If it can help the team... CodeIngiter is so cool for the beginner i am so thank you for your cool work !
(01-12-2018, 11:37 PM)nbbeliard Wrote: Hi, Update to 3.1.6. Is it on the same server or different? Check the upload folder permission
Hi and TY for your answer.
It's the same server, my provider lets us choose PHP version we want. I have a "selector" in cPanel. So i'm absolutly sure it's the single difference between the 2 tests. I understand why you move my post but i repeat my problem isn't the foreach warning... I have solved it alone. I never met this problem before because i've never got error with uploading before... So this condition never be used. The main question is : why upload function failed with PHP 7.2 when it perfectly works with PHP 7.1 ? Permissions are same... and no one other parameter is different. I have no one PHP error... and i have no one $this->upload->display_errors(); return... hum... So it's not a problem for me because i can stay with PHP 7.1... I just thought that it could be usefull for you to know this difficulty exists as exemple of PHP version changing complications. Maybe I'll try to upload codeigniter to 3.1.6 but I have to study the update procedure first. If I do, I will give you news about new PHP 7.2 try.
(01-13-2018, 12:24 AM)nbbeliard Wrote: Hi and TY for your answer. upload work with php 7.2. Check the php error log |
Welcome Guest, Not a member yet? Register Sign In |