[SPT/CWIS] Axis Database Issue

Justin Slauson jslauson at stat.osu.edu
Wed May 28 13:19:46 CDT 2008


On May 28, 2008, at 12:43 PM, Edward Almasy wrote:
> 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.



Your guess was correct, we do use the same credentials as CWIS for our  
own DB calls, and adding the TRUE parameter fixed the problem, we no  
longer get any warnings or errors.  Thanks so much! :)

-Justin



More information about the SPT-CWIS-Users mailing list