Forums
This topic is locked
Creating several PHP Sessions from MySQL
Posted 10 Sep 2002 13:44:56
1
has voted
10 Sep 2002 13:44:56 Abstract Chap posted:
Hoping some one can spot my error or just tell me a better way of doing this.What I wanted to do was have a simple table in MySQL called "config" with two fields "configname" and "configvalue", then I would populate the table with setting for my web site, such as:
configname configvalue
sitename ABC Systems Limited
siteurl www.abc.com
backcolour #FFFFFF
All so I can edit the site online and update many pages at the same time, and also add new config items as needed.
Using PHP 4.2.1 & MySQL on IIS, with PHPAkt 1.5.1 in UD4 created the following code:
<?php
$rs_config = $conn_topsites->Execute("SELECT * FROM bmts_config" or KT_DIE($conn_topsites->ErrorNo(),$conn_topsites->ErrorMsg());
$rs_config_numRows=0;
$rs_config__totalRows=$rs_config->RecordCount();
session_start();
$repeat_rs_config__numRows = -1;
$repeat_rs_config__index= 0;
$rs_config_numRows = $rs_config_numRows + $repeat_rs_config__numRows;
while (($repeat_rs_config__numRows-- != 0) && (!$rs_config->EOF))
{
$confighandle = "bmts_";
$confighandle .= $rs_config->Fields("configname"
session_register( '$confighandle' );
$confighandlevalue = $rs_config->Fields("configvalue"
$confighandle = $confighandlevalue;
$repeat_rs_config__index++;
$rs_config->MoveNext();
}
// session_unset();
$rs_config->Close();
?>
Then I tried to use the session values like such <title><?php echo $bmts_sitename ?></title> however evey value appears empty.
Looking as the seesion file on the server I get the following so think the sessions names are being created ok, but the values are not being assigned.
!bmts_sitename|!bmts_siteurl|!bmts_backcolourl|!
Hope that makes sense, and someone can help me .....please....
Thanks
Stephen
Replies
Replied 10 Sep 2002 21:55:19
10 Sep 2002 21:55:19 Michael O'Neill replied:
You may try changing
session_register( '$confighandle' );
to
session_register( 'confighandle' );
Hope this helps!
session_register( '$confighandle' );
to
session_register( 'confighandle' );
Hope this helps!