Re: Pass mysql array into SESSION?

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

 



Jerry Swanson wrote:
> I want to pass an array from one page to excell generation page. I
> tried to pass through session($_SESSION['sql'] = $var). But value is
> not set.
>
> The array is actually $result = mysql_query($query);

The result from mysql_query() is not an array.

It's a MySQL result reference.

It is tied, by its nature, to the MySQL link (connection) object from
mysql_connect.

Neither the result objects, nor the link object, can survive the end of a
PHP script, for technical reasons.  Actually, maybe some day somebody can
make this work, but it would be real [bleep].  Plus, you'd really only
want to use this in extreme circumstances, despite the seemingly obvious
bonus of expensive database connections surviving for true re-use.

Anyway, back to the more mundane level of your problem:

Use mysql_fetch_array (or mysql_fetch_row, or whatever) to actually get
the content you need, and you can save that in your session.

Depending on how much data you are saving, and how large the strings are
(War and Peace?) you might actually be better off just re-doing the query
in the next script.  You'll have to test on *YOUR* data on *YOUR* server
to be sure either way.  Too many variables render anybody else's data
(mostly) meaningless.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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