PHP5 Anyone see what I'm doing wrong in this small script ... am crying at the moment


Well-known member

$dbhost = 'host';
$dbuser = 'user';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'database';
mysql_select_db($dbname) or die ("Database Selection Wrong");

$backupfile = "holycowitsdata.sql";
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupfile";


echo("done and dusted");

It's generating the backupfile but is not actually dumping any data to it ....
By the way, you do not need to connect to the database from the php script, you only need to execute mysqldump command and it will connect and dump everything itself.
You have a space between -p and your password ($dbpass).

Thanks dude, working like a charm :)

g0rn am opening the database to ensure I have the correct details as this small script is being run over multiple dbs for a full scale move. An open ensures I have the correct details each time it's run.
Top Bottom