problem connecting with 2 databases
Posted: Fri May 20, 2011 6:36 pm
Hey I need some help with using 2 databases
this is for a script to chk the licensing what needs to happen is when a user installs the script it creates a file with the db info in it then at the end it generates a code and I need to connect back to the main site where the script was purchased from and insert the info into the table.
Here is my code so far
$dbc is for the file that was created
$dbc2 is the file used to connect to the main site
thats no problem however I need to insert the info into a table related to $dbc2 i have tried different ways like
but nothing works i also need to select from a table from the users site with $dbc i tried this for that...
the problem is getting the querys to work with selecting and insertings from both databases
any help would be nice.
thanks
this is for a script to chk the licensing what needs to happen is when a user installs the script it creates a file with the db info in it then at the end it generates a code and I need to connect back to the main site where the script was purchased from and insert the info into the table.
Here is my code so far
Code: Select all
<?PHP
require_once('db.php');
$dbc = db_connect();
require_once('db_license.php');
$dbc2 = db_connect2();
require_once('random_ticket_id.php');
$ticketId = generateTicketId ();
?>
$dbc2 is the file used to connect to the main site
thats no problem however I need to insert the info into a table related to $dbc2 i have tried different ways like
Code: Select all
$r= "INSERT into table(id,domain)VALUES(null,'{$var['db_field']}')",$dbc2;Code: Select all
$q = mysql_query("SELECT * FROM table WHERE id='1', $dbc1") or die(mysql_error());
$var= mysql_fetch_array($q, MYSQL_ASSOC);
@mysql_free_result($q);
any help would be nice.
thanks