Reply to Re: "Array to String Conversion" error when constructing a multi-dimensional array

Your name:

Reply:


Posted by drako on 01/22/07 14:10

I got this working in the end. It seemed that having the following
variables caused some clash:

$_POST['increment']
$_SESSION['increment']

once I changed this to $_SESSION['increments'] (notice the plural),
then it was creating arrays within the session variable as expected,
and I can now run it through a 'foreach' loop and 'array_multisort' in
order to process the array data.

Thanks for all your help and suggestions on this one.

Rgds
Neil.


Curtis wrote:
> On Jan 19, 5:15 am, "Rik" <luiheidsgoe...@hotmail.com> wrote:
> > drako wrote:
> > > OK,
> >
> > > Here is the code in its entireity:
> >
> > > [It is wrapped around an IF statement to process upon a certain
> > > condition].
> >
> > > if($_POST['increment'] == 1) {
> >
> > > $x = 0;
> >
> > > if(isset($_SESSION["increment"])) {$x =
> > > count($_SESSION["increment"]);}
> >
> > > $_SESSION["increment"][$x] = array("increment_bond" =>
> > > $_POST["increment_bond"],
> > > "increment_amount" => $_POST["increment_amount"],
> > > "increment_comm_date1" => $_POST["increment_comm_date1"],
> > > "increment_comm_date2" => $_POST["increment_comm_date2"],
> > > "increment_comm_date3" => $_POST["increment_comm_date3"]);
> >
> > > }Is your $_SESSION['increment'] accessed/altered anywhere else in the
> > script? Check for it.
> > Also, add this before "if($_POST['increment'] == 1)":
> >
> > if(isset($_SESSION['increment'])) var_dump($_SESSION['incremenet']);
> >
> > Most likely, you overwrite the $_SESSION['increment'] somewhere else in
> > your code, so it get's cast to a string. Check your code for every
> > '$_SESSION['increment']= ', and carefully consider the return of the
> > function after it...
> > --
> > Rik Wasmus
>
> Concerning your earlier post, great deductive reasoning, Rik. *bows*
>
> Just to reiterate to the OP, you need to check if you're assigning
> $_SESSION['increment'] a function's return value, or possibly even
> directly a string, at some other point (potentially in a different
> file, since it is a session variable).
>
> Also, you could a foreach loop, so as not to manually maintain the
> array's index.
> ---
> Curtis

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация