json_decode problem

I am having a problem with json_decode. I know php does not care what browser you are using, but there is a problem when using Firefox and IE6. I am submitting a form that is encoding it into this:


[ul][{“pprtv_type_id”:"",“pprtv_type”:“HWIR”,"newRecord ":true}][/ul]


[ul]"[{“pprtv_type_id”:"",“pprtv_type”:“HWIR”," newRecord":true}]"[/ul]

Both of these appear to be valid JSON. However, when it reaches the foreach loop IE does not recognize the $array variable as an array so foreach is never executed. Because it is never executed, the record is not being updated or inserted. Does anyone have an idea why this is not working? By the way, I have checked magic_quotes, and they are off.

	require "../../../desktop.php";
	function getInformation($jsondata){
		$jsondata = stripslashes($jsondata);
		$array = json_decode($jsondata,true);
		$msg = NULL;
		$totalCount = 0;
		foreach($array as $value) {
			$totalCount ++;
			$msg .= changeRec($value['pesticide_id'], $value['pesticide'], $value['newRecord']) . ",";
		echo '{"success":true, "totalCount":' . $totalCount . ',"results":[' . substr($msg, 0, -1) . ']}'; 
	function changeRec($id, $dirtyValue, $newRecord){
		//global $tblname;
		$db = new sql();
		$uid = $db->get_member_id();
		$sql = "SELECT * FROM pesticide WHERE pesticide = '$dirtyValue'";
		$rs = $db->sql_query($sql);
		$rows = $db->num_rows($rs); 
		$arr = $db->fetch_array();

		if ($rows >= 1 ){
			$msg =  '{"success":false, "msg":" Pesticide = ' . $dirtyValue . ' already exists. <br />"}';
			$sql2 = updateRec($id, $dirtyValue, $uid, $newRecord);
			$rs2 = $db->sql_query($sql2);
			$msg = '{"success":true}'; 
		return $msg;
	function updateRec($id, $dirtyValue, $uid, $newRecord){

		if ($newRecord){
			$sql2 = "INSERT INTO pesticide (pesticide, mod_user) VALUES ('$dirtyValue', $uid)";
			$sql2 = "UPDATE pesticide
				SET pesticide='$dirtyValue',
				WHERE pesticide_id=$id";
		return $sql2;



Sponsor our Newsletter | Privacy Policy | Terms of Service