Jump to content

2 Databases


me102

Recommended Posts

Basicly theres input box where people put there database details then on the next page it check the database details and if everythings ok it adds the details to the database. My problem is the 2 database connections are not working together and I was wondering what I could do?

 

include(config.php)

 

$testconnect = @mysql_connect($mysql_host,$mysql_username,$mysql_password);

if(!$testconnect ){    echo "error can not connect to database";  }else{ $add = mysql_query(" INSERT INTO DATABASE () VALUES () }

 

config.php


$database_a = mysql_connect($host,$username,$password);

$database_1 = mysql_select_db($database, $database_a);

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/141553-2-databases/
Share on other sites

What exactly is your problem?

 

 

 

Nothing should be wrong with those scripts.

 

 

By the way, you have to pass the DB link resource into mysql_query if you want it to act on a specific connection.  http://php.net/mysql_query

 

 

You should also know that putting in the same host/port will usually return the same connection.

 

 

C:\Users\Corbin>php -r "var_dump(mysql_connect('localhost', 'root', 'root')); var_dump(mysql_connect('localhost', 'root', 'root'));"

resource(5) of type (mysql link)

resource(5) of type (mysql link)

 

I'm not sure what the logic behind it was when the MySQL extension had that coded into it, but that's how it works.

Link to comment
https://forums.phpfreaks.com/topic/141553-2-databases/#findComment-740948
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.