开发者

PHP foreach error "Invalid argument supplied for foreach"

Merged with PHP JSON parsing giving an error.

I was previously using this code and it worked perfectly fine, but when I put it on another server just now it st开发者_Go百科arted 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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜