[SPT/CWIS] Axis Database Issue
Edward Almasy
ealmasy at scout.wisc.edu
Wed May 28 11:43:10 CDT 2008
On May 27, 2008, at 12:31 PM, Justin Slauson wrote:
> In order to have access to the $User object and methods site-wide
> outside of just the CWIS pages (to display login information and
> restrict certain parts to certain users) I include the following line
> in all my scripts:
> include_once('/home/cause/WWW/cwis/include/SPT--Common.php');
> However, I get
> SQL Statement: SELECT * FROM APSessions WHERE SessionId = '517898140'
> SQL Error: Table 'cause.APSessions' doesn't exist
> on any page where I open a database connection. It appears that the
> Axis engine is trying to use our database (`cause`) instead of the one
> for CWIS. This happens even though I close my connection when
> finished, and Axis should have it's own link resource anyway.
What's probably going on is that a database connection is opened and a
database is selected when SPT--Common.php loads the session
information, and then when you do a call later to mysql_connect() it's
reusing that same connection (mysql_connect() does that if the host/
user/password are the same). As you're presumably also doing a call
to mysql_select_db() to select the "cause" database, that overrides
the earlier database selection (done when SPT--Common.php was loaded),
and when the SPT/CWIS code tries to access the DB again it gets the
wrong database.
The solution is to set the $new_link parameter to mysql_connect() to
TRUE when you connect to your database, to make sure you're getting a
new connection and not reusing the one opened earlier by SPT--
Common.php.
Ed
---
Edward Almasy ealmasy at scout.wisc.edu
Co-Director 1210 W Dayton Street
Internet Scout Madison WI 53706
Computer Sciences Department 608-262-6606 (voice)
University of Wisconsin - Madison 608-265-9296 (fax)
More information about the SPT-CWIS-Users
mailing list