Hi, I am having problems with the following, it wont select the second database. $db1 = mysql_connect('localhost', 'user', 'pass'); $sel1 = mysql_select_db('database'); $result = mysql_query("SELECT * FROM `cms_users`", $db1); while ($row = mysql_fetch_assoc($result)) { $db2 = mysql_connect('localhost', 'user', 'pass'); $sel2 = mysql_select_db('database'); $backup = new iam_backup("localhost", $row['dname'], $row['user'], $row['pass'], true, false, true, "../uploads/backup/file.sql.gz"); $backup->perform_backup(); ftp_upload_backup("../uploads/backup/file.sql.gz"); } PHP: Cheers, Adam
ok, try this first. $sel1 = mysql_select_db('database_name',$db1); $sel2 = mysql_select_db('database_2_name',$db2); first it should be two different names of databases. not sure. if the above doesn't work you will have to define the db table as well. mysql_select_db('database2_name.table_name',$db2); and you might get the first step to work but I've had it fail (after working for 3 days!)
You shouldn't have to connect twice. I think there is also a way you can select different db's by doing database.tablename database2.tablename in your queries but don't quote me on that Cheers,
Connect #1, Close #1, Connect #2 .. Try this : $db1 = mysql_connect('localhost', 'user', 'pass'); $sel1 = mysql_select_db('database'); $result = mysql_query("SELECT * FROM `cms_users`", $db1); while ($row = mysql_fetch_assoc($result)) { mysql_close($db1); // Close the previous connection $db2 = mysql_connect('localhost', 'user', 'pass'); $sel2 = mysql_select_db('database'); $backup = new iam_backup("localhost", $row['dname'], $row['user'], $row['pass'], true, false, true, "../uploads/backup/file.sql.gz"); $backup->perform_backup(); ftp_upload_backup("../uploads/backup/file.sql.gz"); } PHP:
Hi, I have tried all these but none seem to be working. I don't get an error it just runs for about half a second and stops. Any other ideas? Cheers, Adam
Any chances to see your Apache error log ? No errors in your browser does not mean that there are no errors at all !