forum.coppermine-gallery.net

Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: bmd_online on July 31, 2005, 12:24:15 pm

Title: Error with database name prefix in queries...
Post by: bmd_online on July 31, 2005, 12:24:15 pm
When connecting to my gallery, I have this error :
Code: [Select]
While executing query "delete from `bmd.online`.cpg_sessions where time<1122742088 and remember=0;" on Resource id #5

mySQL error: Incorrect table name 'cpg_sessions'

(I have replaced my database name (from my provider) with "bmd.online". My real database name was "firstname.lastname").

In the file bridge/coppermine.inc.php, I have changed (lines 68-70)
Code: [Select]
                $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users'];
                $this->groupstable =  '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups'];
                $this->sessionstable =  '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['sessions'];

like this (removed database name).
Code: [Select]
                $this->usertable = $this->db['prefix'] . $this->table['users'];
                $this->groupstable =  $this->db['prefix'] . $this->table['groups'];
                $this->sessionstable =  $this->db['prefix'] . $this->table['sessions'];

Now, it works correctly.
Maybe it's due to "dot" in my database name  ???


I'm using latest devel from CVS.
Title: Re: Error with database name prefix in queries...
Post by: Joachim Müller on July 31, 2005, 12:27:02 pm
yes: database names mustn't contain dots! Not a coppermine issue, marking as "invalid"
Title: Re: Error with database name prefix in queries...
Post by: bmd_online on July 31, 2005, 12:31:58 pm
It was due to my provider, it's not my fault !
Version 1.3 working correctly. With this change, 1.4.x works too.

In this topic (http://forum.coppermine-gallery.net/index.php?topic=17088.msg79964#msg79964), I read the same problem in another file :
If you replace that code with :

Code: [Select]
        // Derived full table names
        if (strpos($db_prefix, '.') === false) {
            $this->usertable = '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['users'];
            $this->groupstable =  '`' . $this->db['name'] . '`.' . $this->db['prefix'] . $this->table['groups'];
        } else {
            $this->usertable = $this->db['prefix'] . $this->table['users'];
            $this->groupstable = $this->db['prefix'] . $this->table['groups'];
        }

It will work for both 1.0.3 and 1.1 beta 1.

Should I commit this to devel?
Title: Re: Error with database name prefix in queries...
Post by: Nibbler on July 31, 2005, 12:35:42 pm
That's not the same problem.
Title: Re: Error with database name prefix in queries...
Post by: bmd_online on July 31, 2005, 12:37:32 pm
Sorry, never mind.