FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Access different Database with PhP





Billy Hill
I have a joomla site on my root with a wordpress blog in /blog. I'd like to be able to pull some data out of the wordpress blog and use it in my joomla site.

More specifically, I want to take a count of entries in certain categories and display them. Is that possible?

Thanks in advance! Wink
Diablosblizz
I don't know how both software works, but you can use mysql_query's to select them. Would that work?
Fire Boar
Yes, in the mysql_connect statement you simply specify a different database - specifically the stuff in the wordpress blog.

However, I'd recommend you have the same user assigned to both databases. That way, you can do something like this:

Code:
// Start of your code...
mysql_select_db('wordpressdatabase');

// do stuff with the database and then...

mysql_select_db('joomladatabase');


Alternatively, you could phrase your queries with the name of your wordpress database, followed by a period (.) preceeding the table name. For example:

Code:
SELECT * FROM wordpressdatabase.entriestable
Billy Hill
Fire Boar wrote:
Yes, in the mysql_connect statement you simply specify a different database - specifically the stuff in the wordpress blog.

However, I'd recommend you have the same user assigned to both databases. That way, you can do something like this:

Code:
// Start of your code...
mysql_select_db('wordpressdatabase');

// do stuff with the database and then...

mysql_select_db('joomladatabase');


Alternatively, you could phrase your queries with the name of your wordpress database, followed by a period (.) preceeding the table name. For example:

Code:
SELECT * FROM wordpressdatabase.entriestable


That looks like it should work. I will play around with it tonite. (Please note that PhP and MySQL are not my thing, but I'm ok with VB and Access databases, so I should be able to make the transition.)

Thanks much! Wink
Related topics
HTTP AUTH with PHP and mySQL
C++ Microsoft Access Database
New CMS - ToendaCMS - No database necessary!
Database/PHP/Cron Jobs [Resolved]
Need Help in PHP
md5 encryption not reliable.
Connect to database that is a not localhost
Authentication Module
What happened to Perl?
Access database from other site ???
ASP vs PHP
Frihost PHP Account
server access, PHP vs AJAX
Remote access to database
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.