Home > Other Systems (CPVLab, iMobiTrax, P202, Track Revenue, Click, Google Analytics, etc.) > The STM Mobile Tracker

stm202 error Invalid argument supplied for foreach 202-account/ajax/alerts.php (6)


11-25-2013 01:25 PM #1 affempire (Member)
stm202 error Invalid argument supplied for foreach 202-account/ajax/alerts.php

i'm using stm202 v4 ,install it on vps hosting,now get this error Warning: Invalid argument supplied for foreach() in /www/stm202/202-account/ajax/alerts.php on line 13 ,how to fix this?? thanks


11-25-2013 03:51 PM #2 caurmen (Administrator)

OK, this is a weird one! I've not seen this error before, I must admit.

Did you follow the STM install guide at http://stmforum.com/forum/showthread...e-Tracker-V3-4 ? If so, at what stage did this error show up?


11-25-2013 06:45 PM #3 kyleirwin (Member)

It's normal. It just means you have no alerts and the code is erroring out because it's trying to show you alerts that aren't in the array.

UPDATE---

It's the 202 alerts RSS feed. It will error out if the install is new and 202 hasn't fetched the RSS "alerts" yet. Below is a fix if anyone is interested, but it's no big deal if left unfixed.

Replace lines 13 thru 26 on 202-account/ajax/alerts.php with the code below.

Code:
if(!empty($rss->items)&&is_array($rss->items)) {
    foreach ($rss->items as $item ) {
        //check if this alert is already marked as seen
        $mysql['prosper_alert_id'] = mysql_real_escape_string($item['prosper_alert_id']);
        $sql = "SELECT COUNT(*) AS count FROM 202_alerts WHERE prosper_alert_id='{$mysql['prosper_alert_id']}' AND prosper_alert_seen='1'";
        $result = _mysql_query($sql);
        $row = mysql_fetch_assoc($result);
        if ($row['count']) {
                #echo 'dont show';
                $dontShow[$item['prosper_alert_id']] = true;
        } else {
                #echo 'show alerts';
                $showAlerts = true;
        }
    }
}else {
    $showAlerts = false;
}


11-26-2013 12:26 AM #4 affempire (Member)

thank you kyleirwin i know


11-26-2013 04:52 PM #5 caurmen (Administrator)

Thanks, kyleirwin!

Much appreciated, I actually didn't know that.


11-27-2013 03:59 PM #6 bbrock32 (Administrator)

Thanks for the patch!

Even though if you disable warnings in PHP all should be good too.


Home > Other Systems (CPVLab, iMobiTrax, P202, Track Revenue, Click, Google Analytics, etc.) > The STM Mobile Tracker