Session variables
| From: | Mick Lloyd | Date: | Tue, 13 Mar 2001 13:55:12 +0000 |
| Subject: | Session variables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-7392@lists.php.net to get a copy of this message | ||
I'm experimenting with sessions and note that you seem to able pass a query
result id via an include but not via an <a href=...>. Is this correct or
have I got it wrong? Do I need to do something to $session[result] before
passing it via <a href>? Example scripts:
session.phtml:
$connection = mysql_connect($DBHost,$DBUser,$DBPass);
mysql_select_db("$DB");
session_start();
session_register("session");
$session["result"]=mysql_query("select * from $TA");
$rows = mysql_num_rows($session[result]);
echo "Rows in session = $rows<BR>";
echo "<a href ='sessionrows.phtml?rows=$rows'>Pass</a><BR>";
echo "<a href
='sessionresultid.phtml?resultid=$session[result]'>Send</a><BR>";
include ("sessionresult.phtml");
sessionrows.phtml:
echo "<br> Rows in sessionrows = $rows";
sessionresultid.phtml:
$rows = mysql_num_rows($resultid);
echo "<br> Rows in sessionresultid = $rows";
sessionresult.phtml:
$rows = mysql_num_rows($session[result]);
echo "Rows in sessionresult = $rows<BR>";
Output from session.phtml reads:
Rows in session = 7
Pass
Send
Rows in sessionresult = 7
Clicking on Pass outputs "Rows in sessionrows = 7" as expected. But Clicking
on Send outputs the "Warning: Supplied argument is not a valid MySQL result
resource ..." error. I also get this when I click Back from either
sessionrows.phtml or sessionresultid.phtml. Again not sure why?
Any help gratefully received.
Mick Lloyd
mjl@consultingrooms.com
Tel: +44 (0)1684 560224