Latest forum threads in my website

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?

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?


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’

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.