I am trying to add in my php script named mysql_connect.php a way to send data to two separate databases at one time with the same scrip. I have tried many different ways to try this, and it either runs the error script or uploads successfully to only one of the two databases. Below is the script if anyone can help. Is there a way to make two database connections with one script?
<?php
DEFINE ('DB_USER', 'user'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'my.server.name.com'); DEFINE ('DB_NAME', 'name'); // Make the connection. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL this time: ' . mysql_error() ); // Select the database. @mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() ); // Create a function for escaping the data. function escape_data ($data) { // Address Magic Quotes. if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } // Check for mysql_real_escape_string() support. if (function_exists('mysql_real_escape_string')) { global $dbc; // Need the connection. $data = mysql_real_escape_string (trim($data), $dbc); } else { $data = mysql_escape_string (trim($data)); } if (function_exists('mysql_real_escape_string')) { global $other; // Need the connection. $data = mysql_real_escape_string (trim($data), $other); } else { $data = mysql_escape_string (trim($data)); } // Return the escaped value. return $data; } // End of function. ?>