Database connection issue

I’m having a few problems with a blog I’m moving to a new site. Everything is set up correctly and I can log into the admin and create posts etc. The problem is when I go to the blog itself. I just get an error which says ‘Can’t change database ()’ and I’m not sure how to fix this.

I’m trying to change the database by using this:

selectdb( "wordpress","dbLinkInt" );
  $query="select * from blog_options";
  $result=dbselect( $query,"dbLinkInt" );

the selectdb function is:

function selectdb( $dbase,$dblink ) {
    if( $GLOBALS[$dblink]->use_db( $dbase ) ) {
    } else {
      if( $GLOBALS['debug'] ) {
        die( 'Can't change database ('.$GLOBALS[$dblink]->connect_errno.') '.$GLOBALS[$dblink]->connect_error );
      } else {
        logdberr( 'Can't change database...','Connect Error ('.$GLOBALS[$dblink]->connect_errno.') '.$GLOBALS[$dblink]->connect_error );
        header( "Location: /dberror.php" );

Have you done a var_dump() on $GLOBALS to check that what’s in there is what you’re expecting to be there and that there’s nothing missing that you’re expecting to be there?

Look at this

logdberr( 'Can't change database...','Connect Error ('.$GLOBALS[$dblink]->connect_errno.') '.$GLOBALS[$dblink]->connect_error );

You have a ’ in the word “Can’t”. That screws up the string. Make it this

logdberr( 'Cant change database...','Connect Error ('.$GLOBALS[$dblink]->connect_errno.') '.$GLOBALS[$dblink]->connect_error );

You could escape it but let’s forego proper grammar for now :wink: .

To PHP gurus - if I still did this line wrong (untested) please feel free to correct it. Something about this line needs fixing.

I tried that but it did it didn’t output anything. I’ve got this working on another domain and it works there. This is on the same server and uses the same database so I don’t understand why it’s not working :frowning:

Sorry that was my bad typing, I’d actually put cant but my computer auto-corrected it.

I’m still not able to connect to the database and am at a lose as to what the problem is.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.