RE: [PHP] seesion_register() with arrays
| From: | John Holmes | Date: | Sat, 01 Jun 2002 00:13:28 +0000 |
| Subject: | RE: [PHP] seesion_register() with arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-100195@lists.php.net to get a copy of this message | ||
$array only contains one of the result rows, not all of them. At least
it's that way in your script. Try to register the variable before you
start assigning values to it and you'll have to add each row into an
array in order to save the entire result set.
---John Holmes...
> -----Original Message-----
> From: Douglas - IG [mailto:douglas.pessoal@ig.com.br]
> Sent: Friday, May 31, 2002 7:17 PM
> To: php-general@lists.php.net
> Subject: [PHP] seesion_register() with arrays
>
> Hi All,
>
> I´m trying to register into a session an array which has returned from
a
> mysql_fetch_array function. But when I call $array it returns empty or
> something like this.
>
> Do you know how can I do this operation?
>
> Regards!
>
> Here go my scripts:
> <?
> # script1.php4
> session_start();
> $sql = "select * from table1";
> $result = mysql_query ("$sql");
> ...
> <form name="form1" method="post"
> action="test.php4?session_id=<?echo
> session_id();?>">
>
> while ($array = mysql_fetch_array($result))
> {...}
> session_register ("array");
> ?>
>
> <?
> # script2.php4
> session_start($session_id);
> if (session_is_registered("array"))
> {
> while ($array) {
> echo $array["fieldname"];
> }
> }
> else { echo "Error<br>"; }
> ?>