Forum Moderators: coopster

Message Too Old, No Replies

MySQL database conflicts!

just curious about some errors

         

dreamcatcher

5:46 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use several scripts on my site that use different databases. When I use include files that these scripts use, I get errors to the effect of:

table forum.log doesn`t exist blah blah

For this example the table forum is used in one database and the table log in another.

I get around this problem by juggling the include files around and this works fine.

Just out of curiosity, I was wondering if there was something that you can write in your PHP code that prevents this conflict happening? Or is it a common thing when using different database include files?

Thank you.

Timotheos

7:39 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are using two connections then are you specifying the link resource in the mysql_query [php.net]?

dreamcatcher

9:04 pm on Feb 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Timotheos. Yep, specifying the link resource ok. Its no big deal really, its just that someone was asking me about it this week with some scripts they were using and I remembered having a similar problem last year.

coopster

1:50 pm on Feb 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could keep your database-specific scripts in separate include folders:

/
¦-cgi-bin
¦-files
¦-includes1 <------browsers can't get here
---first.inc
---second.inc
¦-includes2 <------browsers can't get here
---first.inc
---second.inc
¦-logs
¦-www <-----------public area
---about.htm
---contact.htm
---index.php

Then in the top of your processing script, change the include path for the duration of the script processing:

// Works as of PHP 4.3.0
set_include_path [php.net](get_include_path [php.net]() . '.: [php.net]'
. $_SERVER['DOCUMENT_ROOT'] . '/../includes1/');
#
# ...OR...
#
// Works in all PHP versions
ini_set [php.net]('include_path', ini_get [php.net]('include_path') . '.: [php.net]'
. $_SERVER['DOCUMENT_ROOT'] . '/../includes1/');

dreamcatcher

5:58 pm on Feb 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for that coop. :)