We have the chunk of code at the bottom of the page. It is behaving very strangly under php 4.3.9. Basically, if it is not coded exactly as listed below, it will not work right. The development server is running 5.0.3, and it works fine. However, the live server has 4.3.9. Is there something vastly different with arrays and session variables?
$key = $_REQUEST['quote'];
$quotes = $_SESSION['quotes'][$key];
//unset($_SESSION['quotes'][$key]);
$doc = $file_array[$key];
// handle a new quantity request
if(isset($_REQUEST['qty']) && preg_match('/^\d+$/',$_REQUEST['qty']))
{
if(!(is_array($quotes)))
$quotes = array();
//print $_REQUEST['qty'];
$found = false;
if(count($quotes) > 0)
{
foreach($quotes as $qty)
{
if($qty == $_REQUEST['qty'])
$found = true;
}
}
//print_r($quotes);
if(!$found) {
print "Before";
print_r($quotes);
array_push($quotes, $_REQUEST['qty']);
print "After";
print_r($quotes);
$quoteString = implode(",",$quotes);
$_SESSION['quotes'][$key] = explode(",",$quoteString);
} else {
$quoteString = implode(",",$quotes);
$_SESSION['quotes'][$key] = explode(",",$quoteString);
}
//print_r($quotes);
//sort($quotes);
//print_r($quotes);
//print_r($_SESSION['quotes'][$key]);
//$_SESSION['quotes'][$key] = array();
//$quotes = $_SESSION['quotes'][$key];
print "Session";
print_r($_SESSION['quotes'][$key]);
$key = $_REQUEST['quote'];
$quotes = $_SESSION['quotes'][$key];
//unset($_SESSION['quotes'][$key]);
$doc = $file_array[$key];
// handle a new quantity request
if(isset($_REQUEST['qty']) && preg_match('/^\d+$/',$_REQUEST['qty']))
{
if(!(is_array($quotes)))
$quotes = array();
//print $_REQUEST['qty'];
$found = false;
if(count($quotes) > 0)
{
foreach($quotes as $qty)
{
if($qty == $_REQUEST['qty'])
$found = true;
}
}
//print_r($quotes);
if(!$found) {
print "Before";
print_r($quotes);
array_push($quotes, $_REQUEST['qty']);
print "After";
print_r($quotes);
$quoteString = implode(",",$quotes);
$_SESSION['quotes'][$key] = explode(",",$quoteString);
} else {
$quoteString = implode(",",$quotes);
$_SESSION['quotes'][$key] = explode(",",$quoteString);
}
//print_r($quotes);
//sort($quotes);
//print_r($quotes);
//print_r($_SESSION['quotes'][$key]);
//$_SESSION['quotes'][$key] = array();
//$quotes = $_SESSION['quotes'][$key];
print "Session";
print_r($_SESSION['quotes'][$key]);