Osclass Support Forums

Osclass plugin support => Image Required Plugin => Topic started by: aroca on April 29, 2016, 06:25:35 AM

Title: ERROR When no picture added
Post by: aroca on April 29, 2016, 06:25:35 AM
Error when no picture added (we tested if user will not add picture)

ERROR:
Warning: Illegal string offset 'name' in /xx/xx/public_html/xx/oc-content/plugins/image_required/index.php on line 78

Warning: Cannot modify header information - headers already sent by (output started at /xx/xx/public_html/xx/oc-includes/osclass/utils.php:1740) in /xx/xx/public_html/xx/oc-includes/osclass/utils.php on line 1745


Line 78
    $img_uploading = count($aItem['photos']['name']);


Lines 1738-1748
function osc_redirect_to($url, $code = null) {
    if(ob_get_length()>0) {
        ob_end_flush();
    }
    if($code!=null) {
        header("Location: ".$url, true, $code);
    } else {
        header("Location: ".$url);
    }
    exit;
}


What to do? Thank you!
NOTE: No problem if with picture :))
Title: Re: ERROR When no picture added
Post by: MB Themes on April 29, 2016, 06:54:59 AM
@aroca
Well that is interesting, as PHP control should never be activated on site without errors.
Unfortunately I cannt get such problem, please PM me login to your FTP and your URL so I can investigate what is issue.

Thanks
Title: Re: ERROR When no picture added
Post by: sachinthana on June 11, 2016, 11:00:20 AM
same issue on my site.

Warning: Illegal string offset 'name' in #/oc-content/plugins/image_required/index.php on line 78

Warning: Cannot modify header information - headers already sent by (output started at #/oc-includes/osclass/utils.php:1740) in #/oc-includes/osclass/utils.php on line 1745

please solve this issue.
Title: Re: ERROR When no picture added
Post by: MB Themes on June 11, 2016, 08:09:21 PM
@sachinthana
As I cannot replicate problem, PM me login to your ftp & oc-admin.
Title: Re: ERROR When no picture added
Post by: MB Themes on June 13, 2016, 12:15:42 PM
@aroca, @sachinthana
I think I have identified problem.
To fix, please go to file:
oc-content/plugins/image_required/index.php

Find code (there are 2 occurences):
Code: [Select]
    $img_uploading = count($aItem['photos']['name']);
    $img_count = $img_exists + $img_uploading;

Replace with (both of them):
Code: [Select]
    if(array_key_exists('name', $aItem['photos'])) {
      $img_uploading = count($aItem['photos']['name']);
      $img_count = $img_exists + $img_uploading;
    } else {
      $img_count = 0;
    }