Re: session_name("CCLTrolley")

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert Cummings wrote:

Is there a reason you're using a comma delimited string? I would
recommend using an array instead:

<?php
session_name( 'CCLTrolley' );
session_start();
// Initialize the trolley.
if( !isset( $_SESSION['TrolleyContents'] ) )
{
   $_SESSION['TrolleyContents'] = array();
}
// Add new entry.
if( isset( $_POST['RNum'] ) )
{
   $_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
}
echo implode( ',', $_SESSION['TrolleyContents'] );
print_r($_SESSION);
?>

Cheers,
Rob.

Hi,
Still absorbing this array stuff :).
I'm getting this error. And when RNum = 1 or = 16 or = 116, it only registers '1', or whatever the first digit is.

Warning: Bad arguments to implode() in /var/.../printtrolley.php on line 14
Array ( [TrolleyContents] => 1 3 4 4 5 6 )

I was expecting to see soemthing like:

TrolleyContents[16]
TrolleyContents[32]
TrolleyContents[45]
TrolleyContents[48]
TrolleyContents[55]
TrolleyContents[116]

if I have done my homework, since last night ;), correctly?

The manual example says:
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated; // lastname,email,phone
?>

What is my correct seperator? And why does only one digit get registered?

Thanks,
John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux