View Full Version : Warning: Cannot use a scalar value as an array
Ashif
05-24-2006, 01:00 PM
Getting This warning...
Warning: Cannot use a scalar value as an array
$_SESSION['quantity'][$ind] = $qty;
$ind is an Integer type variable
and $qty is also an integer type variable..
and what i am missing, .. ?
d11wtq
05-24-2006, 11:54 PM
You sure it's an integer? var_dump() it. Or just explicitly (int) cast it.
I'm not even sure that's the issue, it sounds more like something has screwed with $_SESSION itself... does assigning anything else to the session in this page work?
Ashif
05-25-2006, 01:23 AM
well i have some how over come that problem, its now assigning.. the quantity the right value, however i have explicity typcast the $qty to int...
NOW
$_SESSION['itemstray'][0] = "";
$_SESSION['quantity'][0] = "";
$_SESSION['unit'][0] = "";
$_SESSION['size'][0] = "";
using
print_r($_SESSION);
it shows that itemstray and quantity as arrays
while unit and size as single variable
y ?
NOW, when i changed the SESSION variable names to
$_SESSION['itemstray'][0] = "";
$_SESSION['quantity'][0] = "";
$_SESSION['itemunit'][0] = "";
$_SESSION['psize'][0] = "";
unit to 'itemunit'
size to 'psize'
then using
print_r($_SESSION);
it showed that the itemunit, and psize are also arrays..
whats the difference ?, are unit, size any reserved words ?
d11wtq
05-25-2006, 08:13 PM
I think you need to show us some more code. There's clearly something wrong with the logic somewhere ;)
Schiller33
05-31-2006, 03:55 PM
Hi,
maybe you have register_globals turned ON and use vars with the names "unit" and "size". If this is the case you overwrite your session with the same names.
Greetings from Germany
Joerg
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.