WhiskeyMike
05-09-2011, 10:57 PM
Hello folks,
If this topic exists somewhere else on these forums, I apologize. I did do a search and did not find anything relevant. First, here's my script:
// First query to database: A, Table users
$sql = "INSERT INTO users (these, columns) ";
$sql .= "VALUES ('".$these."', '".$variables.") ";
// Do it!
if ($this->db == '' || $this->db != 1) {
$this->db = messagedbconnect(); // Connect function in included file
}
$result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR);
if ($this->db == 1 || $this->db != '') {
messagedbdconnect($this->db); // Disconnect function in included file
$this->db = '';
}
// Second query to database: B, Table members
$sql = "INSERT INTO members (different, columns) ";
$sql .= "VALUES ('".$different."', '".$variables.") ";
// Do it!
if ($this->db == 1 || $this->db != '') {
messagedbdconnect($this->db); // Just in case the other connection is, by some freak of nature, still open, we close it AGAIN
$this->db = ''; // Set the $db property to empty since we disconnected
}
if ($this->fdb == '' || $this->fdb != 1) {
$this->fdb = fdbconnect(); // DIFFERENT connection function in included file
}
$result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR);
if ($this->fdb == 1 || $this->fdb != '') {
fdbdconnect($this->fdb); // DIFFERENT disconnect function in included file
$this->fdb = ''; // Set the $fdb property to empty since we disconnected
}
And the included file:
// WEBSITE CONNECTION DATA //
define('SQL_SERVER','XXXX'); // Database Server
define('SQL_USER','XXXXXX'); // Your mysql User
define('SQL_PASS','XXXXXX'); // Your mysql Password
define('SQL_DB','database1'); // Your mysql database
function messagedbconnect() {
mysql_connect(SQL_SERVER,SQL_USER,SQL_PASS) or die("Error: ".mysql_error()); // Connection to the server
mysql_select_db(SQL_DB) or die("Error: ".mysql_error()); // Connecting to the database
return 1;
}
function messagedbdconnect($connection) {
mysql_close($connection);
return 1;
}
// FORUM CONNECTION DATA
define('FSQL_SERVER','XXXXXX'); // Database Server
define('FSQL_USER','XXXXXX'); // Your mysql User
define('FSQL_PASS','XXXXXX'); // Your mysql Password
define('FSQL_DB','database2'); // Your mysql database
function fdbconnect() {
mysql_connect(FSQL_SERVER,FSQL_USER,FSQL_PASS) or die("Error: ".mysql_error()); // Connection to the server
mysql_select_db(FSQL_DB) or die("Error: ".mysql_error()); // Connecting to the database
return 1;
}
function fdbdconnect($connection) {
mysql_close($connection);
return 1;
}
Now, even though I used mysql_close($this->db), it returns this error as if it's still thinking the "members" table should be part of database1:
MySQL error: 1146 : Table 'database1.members' doesn't exist (# 256)
This is frustrating me to no end... any ideas?
EDIT: I have the same mysql user for both databases, could that be the problem?
If this topic exists somewhere else on these forums, I apologize. I did do a search and did not find anything relevant. First, here's my script:
// First query to database: A, Table users
$sql = "INSERT INTO users (these, columns) ";
$sql .= "VALUES ('".$these."', '".$variables.") ";
// Do it!
if ($this->db == '' || $this->db != 1) {
$this->db = messagedbconnect(); // Connect function in included file
}
$result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR);
if ($this->db == 1 || $this->db != '') {
messagedbdconnect($this->db); // Disconnect function in included file
$this->db = '';
}
// Second query to database: B, Table members
$sql = "INSERT INTO members (different, columns) ";
$sql .= "VALUES ('".$different."', '".$variables.") ";
// Do it!
if ($this->db == 1 || $this->db != '') {
messagedbdconnect($this->db); // Just in case the other connection is, by some freak of nature, still open, we close it AGAIN
$this->db = ''; // Set the $db property to empty since we disconnected
}
if ($this->fdb == '' || $this->fdb != 1) {
$this->fdb = fdbconnect(); // DIFFERENT connection function in included file
}
$result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR);
if ($this->fdb == 1 || $this->fdb != '') {
fdbdconnect($this->fdb); // DIFFERENT disconnect function in included file
$this->fdb = ''; // Set the $fdb property to empty since we disconnected
}
And the included file:
// WEBSITE CONNECTION DATA //
define('SQL_SERVER','XXXX'); // Database Server
define('SQL_USER','XXXXXX'); // Your mysql User
define('SQL_PASS','XXXXXX'); // Your mysql Password
define('SQL_DB','database1'); // Your mysql database
function messagedbconnect() {
mysql_connect(SQL_SERVER,SQL_USER,SQL_PASS) or die("Error: ".mysql_error()); // Connection to the server
mysql_select_db(SQL_DB) or die("Error: ".mysql_error()); // Connecting to the database
return 1;
}
function messagedbdconnect($connection) {
mysql_close($connection);
return 1;
}
// FORUM CONNECTION DATA
define('FSQL_SERVER','XXXXXX'); // Database Server
define('FSQL_USER','XXXXXX'); // Your mysql User
define('FSQL_PASS','XXXXXX'); // Your mysql Password
define('FSQL_DB','database2'); // Your mysql database
function fdbconnect() {
mysql_connect(FSQL_SERVER,FSQL_USER,FSQL_PASS) or die("Error: ".mysql_error()); // Connection to the server
mysql_select_db(FSQL_DB) or die("Error: ".mysql_error()); // Connecting to the database
return 1;
}
function fdbdconnect($connection) {
mysql_close($connection);
return 1;
}
Now, even though I used mysql_close($this->db), it returns this error as if it's still thinking the "members" table should be part of database1:
MySQL error: 1146 : Table 'database1.members' doesn't exist (# 256)
This is frustrating me to no end... any ideas?
EDIT: I have the same mysql user for both databases, could that be the problem?