PHP foreach错误“为foreach提供的参数无效”

时间:2010-09-14 08:26:16

标签: php json foreach

我以前使用过这段代码并且工作得非常好,但是当我把它放在另一台服务器上时它刚开始吓坏了,我将一个JSON对象传递给PHP文件并遍历它,我使用的foreach似乎工作正常,但现在我得到“为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;
?>

我的本​​地主机上的一切都运行良好,所以我不知道为什么会这样轰炸,我真的很感激任何帮助或洞察这个问题,因为我需要尽快解决它!

提前Thanx!

0 个答案:

没有答案
相关问题