is possible ? thanks
Forums
SEND FORM DATA TO AN EXTERNAL MYSQL DATABASE
Hi marco4000,
Yes probably. You'd need to code the connection I think. Or possibly set up a second Joomla DataBase Object.
Bob
Yes probably. You'd need to code the connection I think. Or possibly set up a second Joomla DataBase Object.
Bob
Hi Marco,
you need the to write a new mysql connection, do you have any idea with the PHP code needed to open a new connection to the mysql database ?
let me know!
regards
Max
you need the to write a new mysql connection, do you have any idea with the PHP code needed to open a new connection to the mysql database ?
let me know!
regards
Max
Hi Marco,
From looking at the code I think you can open a new MySQL connection with
Bob
From looking at the code I think you can open a new MySQL connection with
<?php
$options = array('host' => 'xxx', 'user' => 'xxx', 'password' => 'xxx', 'database' => 'xxx', 'prefix' = 'xxx', 'select' => 'xxx');
$db2 =& new JDatabaseMySQL($options);
?>
NB Not tested and may not work!Bob
Hi I am sorry I have been trying to connect to an external database on my localhost with no luck. I've followed your example in the tutorial. I've created a test database called names with a all_names table with two fields: id and name. I've entered two records so that I will have some data. My code is:
It doesn't work. Unfortunately I cannot debug, whenever I set Joomla Debug System to Yes I get a The connection was reset error message.
Is my code correct?
<input name="name" value="<?php
$options = array(
'host' => 'localhost',
'user' => 'root',
'password' => '',
'database' => 'names',
'prefix' = '',
'select' => true
);
$db =& new JDatabaseMySQL($options);
$query = "
SELECT `name`
FROM `all_names`
WHERE `id` = '1';
";
$db->setQuery($query);
$result = $db->loadResult();
echo $result;
?>" />
It doesn't work. Unfortunately I cannot debug, whenever I set Joomla Debug System to Yes I get a The connection was reset error message.
Is my code correct?
Hi your code was wrong. It needed to be
It works now. Regards...
<input name="name" value="<?php
$options = array();
$options['driver'] = 'mysql'; // Database driver name
$options['host'] = 'localhost'; // Database host name
$options['user'] = 'root'; // User for database authentication
$options['password'] = ''; // Password for database authentication
$options['database'] = 'names'; // Database name
$options['prefix'] = ''; // Database prefix
$db = & JDatabase::getInstance($options);
$query = "
SELECT `name`
FROM `all_names`
WHERE `id` = '2';
";
$db->setQuery($query);
$result = $db->loadResult();
echo $result;
?>" />
It works now. Regards...
This topic is locked and no more replies can be posted.