tags:

views:

124

answers:

0

Hi guys, I was previously using this code and it worked perfectly fine, but when I put it on another server just now it started freaking out, I am passing a JSON object to a PHP file and traversing through it, the foreach I used seemd to work fine, but now I get "Invalid argument supplied for foreach",

PHP:

<?php
    $json = $_POST['systems']; 
    $uid = $_POST['uid'];
    $test = json_decode($json, true); 

    mysql_connect('localhost','user','password') or die(mysql_error());
    mysql_select_db('products') or die(mysql_error());

    //insert the suppliers products into the database
    foreach($test as $key){
        $query = mysql_query("INSERT INTO suppliersProducts (product_id, supplier_id) VALUES('".$key['value']."', '".$uid."' ) ") or die(mysql_error());
    }

    echo $uid;
?>

Everything was working fine on my localhost, so I have NO idea why it is bombing out like this, I would really appreciate any help or insight into this problem, as I need to solve it ASAP!

Thanx in advance!