Forums

Connection to external db

gallo 31 Aug, 2009
Hi, i write because i have a curious problem:

i have a multi page form that write into a external db.
I connect 2 time into the db: in step1 and in step2 (of 2 total steps).

in the form html of step1 form i put this code:

$db_host1 = "localhost";
$db_user1 = "********";
$db_password1 = "*******";
$db_name1 = "******";

$mysql_conn1 = mysql_connect($db_host1, $db_user1, $db_password1);

if ($mysql_conn1 == FALSE)
die ("error of connection to database");

mysql_select_db($db_name1,$mysql_conn1)
or die ("error of db connection");

	
	$qry="my query";
	$res=mysql_query($qry,$mysql_conn1) or die ("error 0293");


and this is all rights.

in the form step2 i put the same code (i change only the query) and the query it's ok, but i lost the connection with the joomla db.

what's the solution?
GreyHead 31 Aug, 2009
Hi gallo,

Use the Joomla DB code
<?php
$options = array('host' => 'localhost', 'user' => '********', 'password' => '********', 'database' => '********', 'prefix' = '', 'select' => 'info');
$db2 =& new JDatabaseMySQL($options);
$qry="my query";
$db2->setQuery($qry);
$db2->query();
?>

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger