how to query a different database Hallo,
I want to query a second database in a component.
How can I do that?.
I tryed to open a db
$dbextern = MYSQL_CONNECT($row->moblogDBHostName, $row->moblogDBUserName, $row->moblogDBPassword) OR DIE("Error !! Unable to connect to database");
select a table
mysql_select_db('externdb') or die( "Unable to select database ".$row->moblogDBTable);
start my query.
After getting the correct data from the query I closed the database.
mysql_close($dbextern);
Now I want to insert parts from the queryresults into the mambo database but the following query is looking in the false database for the table.
$database->setQuery("INSERT INTO mos_content ( title, title_alias, introtext, state, sectionid, catid) VALUES ('$post_mail_subject','$post_mail_subject','$post_ mail_body','1','$mossectionid','$moscatid')" );
I get the Error:
Table 'externdb.mos_content' doesn't exist SQL=INSERT INTO mos_content ( title, title_alias, introtext, state, sectionid, catid) VALUES ...
Hope anybody can help me.
Thanks |