asked on
$_SESSION['boxdest2']
<?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');
}
}
?>
white screenThis is usually a symptom of an error occurring in a script that has error reporting disabled. Suggest you add error_reporting(E_ALL) to the top of all your PHP scripts and fix the things that cause error, warning and notice messages. Here is how the session works. Use session_start() before you access any of the contents of $_SESSION.
$row = mysql_fetch_array($result) or die(mysql_error());
That's the wrong way to deal with an empty results set. If your script gets to that line of code, the query was successful! So there is no reasonable expectation that the script should die, nor that mysql_error() would have a meaningful value. If $row is empty, it's because the query did not find anything that matched the WHERE clause. This is a perfectly normal and expected behavior for MySQL databases, and certainly not a reason to terminate the script.
ASKER
If I echo my session var then I can see the data that is being passed is in the format wd10,wd11,wd12
<?php
error_reporting(E_ALL);
session_start();
var_dump($_SESSION);
ASKER
'boxdest2' => string 'WD10,WD11,WD12' (length=14)
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
http://php.net/manual/en/function.session-start.php