foreach循环不返回$ _SESSION变量的值

时间:2017-04-15 09:52:44

标签: php

我设置了一个$ _SESSION变量,但无法看到为什么我的foreach循环不起作用。如果我回应var $ v,我得到的只是一个白色屏幕。如果我回显了会话var,那么我可以看到传递的数据格式为wd10,wd11,wd12。

如果有人能检查我的循环并指出我的错误,我将不胜感激。感谢

我在页面顶部有session_start(),所有会话和mysql查询都正常工作。

<?php
    foreach ($_SESSION['boxdest2'] as $key=>$value)
        {   
      $temp = explode(",", $value);
      foreach($temp as $k => $v )
      {
        $query = "SELECT * FROM boxes WHERE customer = '$_SESSION[kt_idcode_usr]' AND status = 1 AND custref = '$v'";
        $result = mysql_query($query) or die(mysql_error());
        $row = mysql_fetch_array($result) or die(mysql_error());
        $rack = $row['rack'] . "-" . $row['column'] . "-" . $row['row'] .  "-" . "(" . $row['bay'] . ")";

    //    $query = "UPDATE boxes SET status = '9' WHERE customer = '$customer' AND department = '$dept' AND custref = '$v'";
    //    mysql_query($query) or die('Error, query failed');
    //  
        $query = 'INSERT INTO `act` (`slot`, `service`, `activity`, `department`, `company`, `address`, `user`, `item`, `destroyedby`, `destroyedby_date`, `date`, `new`) VALUES (\''.$rack.'\', \''.$service.'\', \''.$activitys.'\', \''.$dept.'\', \''.$company.'\', \''.$address.'\', \''.$user.'\', \''.$v.'\', \''.$user.'\',NOW(),NOW(), \''.$new.'\');';
       mysql_query($query) or die('Error, query failed');
        }
        }
?>

0 个答案:

没有答案