Re: [PHP] Pass mysql array into SESSION?

2004-12-09 Thread Richard Lynch
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



[PHP] Pass mysql array into SESSION?

2004-12-08 Thread Jerry Swanson
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);

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



Re: [PHP] Pass mysql array into SESSION?

2004-12-08 Thread Marek Kilimajer
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);
did you call session_start() at the beginning of your scripts? Is the 
query executed without an error? Are there any rows returned?

Start with something simple and see if it works:
Page 1:
session_start();
query database...
print_r() the result
store the result in session variable
link to Page 2
Page 2:
session_start();
print_r the session variable
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


: [PHP] Pass mysql array into SESSION?

2004-12-08 Thread yangshiqi
Yes. And also look at your php.ini, if the session's name and path is not
set ,
You must set it above session_start();
Like :
session_name('test');
session_save_path(/homes/eric/temp);
session_start();
...

--
: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
: 2004129 10:15
: Jerry Swanson
: PHP List
: Re: [PHP] Pass mysql array into SESSION?

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

did you call session_start() at the beginning of your scripts? Is the 
query executed without an error? Are there any rows returned?

Start with something simple and see if it works:

Page 1:
session_start();

query database...

print_r() the result

store the result in session variable

link to Page 2


Page 2:

session_start();

print_r the session variable

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

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