SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    79
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Latest forum threads in my website

    Hello.
    I have a website and I have another URL of the website forums ( same host - different database ).
    How I can impelement latest threads from forum in my website? (I mean, connecting to the database and querying the forum latest posts, and after it's all done, connect back to my original website database)

    Any help?
    Owner of uReviews & MovieDB - Movie Database

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,067
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    You are over thinking this. Simply create a new PHP script, that connects to the forum database (using a unique variable name), queries the data, and closes the connection. So long as you don't re-use the same connection variable name you use for your current website, it won't break your current website.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    79
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    You are over thinking this. Simply create a new PHP script, that connects to the forum database (using a unique variable name), queries the data, and closes the connection. So long as you don't re-use the same connection variable name you use for your current website, it won't break your current website.
    Oh lol. So I just should create a new .php file, put the script in it with the new connection to the new database, using the require() or include() from the original file and it's ready to go?

    Thanks!
    Owner of uReviews & MovieDB - Movie Database

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,067
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by theunreal View Post
    Oh lol. So I just should create a new .php file, put the script in it with the new connection to the new database, using the require() or include() from the original file and it's ready to go?

    Thanks!
    Exactly. And if you are using an ORM of some sort, I'm sure there's a way of handling multiple connections in it as well.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    79
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Exactly. And if you are using an ORM of some sort, I'm sure there's a way of handling multiple connections in it as well.

    Do I have to close the old connection in the new file and start it again after the new code?
    Because it says 'Access denied for user 'apache'@'localhost' (using password: NO'
    Owner of uReviews & MovieDB - Movie Database

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,067
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Can you post the code you wrote, as it seems you didn't specify your username and password correctly for the second database.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    79
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Can you post the code you wrote, as it seems you didn't specify your username and password correctly for the second database.
    It's working now, cloesd the old connection before the file and started it again after it.
    Owner of uReviews & MovieDB - Movie Database


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •