putting info retreived from mysql on the next web page

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pocoloco
Forum Newbie
Posts: 1
Joined: Tue Nov 19, 2002 6:43 pm

putting info retreived from mysql on the next web page

Post by pocoloco »

I have retreived information from my database using SELECT * FROM 'table, this info is stored as $result.

I want to use the info stored as $result on the next page.

I have tried registering $result with a session (i.e. session_register("result") ) and after opening the session i have tried to access the info using mysql_fetch_array. This doesn't work.

Does this make sense?

What do i do?

Do i have to do something with $result before registering it with a session?

Please help a poor <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> off scouser!
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

unfortunately $result does not contain the output of your query. it contains a resource identifier. it points to a temporary table created for the current script/session. once that script complets the temporary table is destroyed and the resource indentifier is no longer any good. without getting complicated the is no easy way to carry over a query from one page to another. best thing to do is re-query in the next page.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You could also save the result of the query into a proper array that you could carry over using sessions:

Code: Select all

$result_array = array();
while ($row = mysql_fetch_assoc($result)) {
    $result_array&#1111;] = $row;
}
Mac
Post Reply