[phplib] Some help please !! From: TRINHL <email protected>
Date: 10/19/00

To whom this may concern,

I'm a "newbie" with PHPLIB. I would appreciate some help in understanding
what may be causing the following problem. I have a simple PHP script page
to INSERT a data record into a MySQL database table. I'd also like to have
some Authentication capability on this page. Here is the code:

<?
page_open(array("sess" => "Valid_Session"));
$db = new DB_Members;
$sql = sprintf("INSERT INTO Members (FirstName, Lastname, Email,
                        AreaCode, Phone, Company, BusAddress, BusCity,
                        BusState, BusZip, BusCountry, BusAreaCode, BusPhone,
                        BusFaxAreaCode, BusFaxNo, UserID, Password)
                VALUES ('$first_name', '$last_name', '$email_addr',
                        '$area_code', '$phone_no', '$company_name',
'$business_address', '$business_city',
                        '$business_state', '$business_zip',
'$business_country',
                        '$bus_area_code', '$business_phone',
'$bus_fax_area_code',
                        '$business_fax', '$user_name', '$userpass') ");

if(!$db->query($sql))
        {
        echo "<b>New member has NOT been added:</b> ", $db->Error;
        exit;
        }
else
        print "User <b>$user_name</b> from <b>$company_name</b> has been
added !";
page_close();
?>

The "sess" name "Valid_Session" has been defined in local.inc as follows:
...
class DB_Valid extends DB_Sql {
  var $Host = "localhost";
  var $Database = "phplib";
  var $User = "root";
  var $Password = "23646";
}
...
class Valid_CT_Sql extends CT_Sql {
  var $database_class = "DB_Valid"; ## Which database to connect...
  var $database_table = "active_sessions"; ## and find our session data in
this table.
}
...
class Valid_Session extends Session {
  var $classname = "Valid_Session";

  var $cookiename = ""; ## defaults to classname
  var $magic = "Hocuspocus"; ## ID seed
  var $mode = "cookie"; ## We propagate session IDs with
cookies
  var $fallback_mode = "get";
  var $lifetime = 0; ## 0 = do session cookies, else
minutes
  var $that_class = "Valid_CT_Sql"; ## name of data storage container
  var $gc_probability = 5;
}
...

I have also declared a DB_Members class from DB_Sql since it is so
convenient to use.
...
class DB_Members extends DB_Sql {
  var $Host = "localhost";
  var $Database = "valid3";
  var $User = "root";
  var $Password = "23646";
}
...
PLEASE NOTE THAT THIS IS A DIFFERENT DATABASE !!

When the above page executes, the new record is properly "inserted" into DB:
valid3. However, I get this error msg when the page_close() is called at the
end.

Database error: Invalid SQL: update active_sessions set
val='VmFsaWRfU2Vzc2lvbjokdGhpcy0+aW4gPSAnJzsgJHRoaXMtPnB0ID0gYXJyYXkoKTsg',
changed='20001019100117' where sid='1fc61324228a0cc35e27d8b73dba7502' and
name='Valid_Session'
MySQL Error: 1146 (Table 'valid3.active_sessions' doesn't exist)

Apparently, it's trying to insert the session record into the
active_sessions table in the valid3 DB. How do I explicit tell PHPLIB that
the session is with DB_Valid and not DB_Members ?

Thank you in advance for anyone who can help !!

Lu Trinh
trinhl <email protected>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>