• I created a Page called editSubscriber, and then created a custom Template for this page so that I could run php/html code within the body. That works fine. The idea is to connect to my database (not my wordpress database but another database on the same server) and SELECT data from it, display it on the page and allow the user to edit the data. This is an internal intranet type page that will be passworded so don’t freak out.

    Anyhow, when i try to connect to this other database from my Template page, it gives me an error that the table I am seeking does not exist. It is doing this because it is looking in the wordpress database and not the other one. My connection code specifically tells it which database to look in, but for some reason it keeps redirecting back to the wordpress database, dos anyone know how to avert this?

    When I run the script from the root wordpress directory it works fine. If I run it from my themes folder, it looks at the wrong database.

    My connection code:

    <?php
    // Makes initial conection to database
    define ('DB_USER', 'username');
    define ('DB_PASSWORD', '********');
    define ('DB_HOST', 'mysql15.myserver.com');
    define ('DB_NAME', 'cmsubsdata');
    
    $connect = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
      	or die('Our database is currently down for updates, please check back later.'); 
    
    $db = @mysql_select_db(DB_NAME, $connect)
    	or die('Our database is currently down for updates, please check back later.');
    	?>
Viewing 8 replies - 1 through 8 (of 8 total)
  • no-ones deleting it — you’re being tagged by askimet. it happens occasionally – relax. ??

    Thread Starter thebindlestick

    (@thebindlestick)

    what does that mean?>

    it means your posts disappear (for one thing),, until a mod fishes them out. Of course, if you repost they just have to pick through more … It’s not the end of the world, and it happens to a lot of people.

    Thread Starter thebindlestick

    (@thebindlestick)

    fishes them out of where? Why do they disappear in the first place?

    I’m not a forum mod, so I cant answer to that —

    All EYE know is that it happens, it can be triggered by posting too quickly, by posting too many links, etc.. it JUST fricken happens sometimes, it’s software – its not perfect.

    Thread Starter thebindlestick

    (@thebindlestick)

    what are the bbpress forums?

    re: your original post. A wordPress created page will be calling the WordPress database first (and thats the important thing to realize). It’s been discussed before. WordPress doesn’t close the MySQL connection so it continuing to look in that db.

    There are more than a few posts here that discuss this – I found them searching for mysql_close() …

    The simple way to fix this is to NOT create the page using WP. but there are other ways too.

    here’s a good read, that will probably help:

    https://www.scriptygoddess.com/archives/2004/06/15/php-working-with-multiple-databases/

    Re: the askimet thing: Im not feeling chatty enough to continue.

    In reference to that scriptygoddess solution, where would i find the database connection code to alter it? What file is it in?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Database Connection in WordPress’ is closed to new replies.