Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.