简体   繁体   中英

php mysql dump not working

I know there are several questions related to this issue. I tried many things but nothing worked so I posted this again.

I am trying to create a whole db backup in SQL format using php and mysqldump. I have the code working few days ago but then suddenly it stopped and it doesn't work any more. Here is my code:

$q = "mysqldump --user=$mysqlUserName --password=$mysqlPassword --host=$mysqlHostName $mysqlDatabaseName > $mysqlExportPath";
exec($q, $output = array());

It gives me this warning and also does not create the sql backup.

Strict Standards: Only variables should be passed by reference

I am stuck, please help me. My server is on Codero and linux based.

It may help you

$q = "/usr/bin/mysqldump -u $mysqlUserName -p $mysqlPassword -h $mysqlHostName $mysqlDatabaseName > $mysqlExportPath";
$output = array();
exec($q, $output);

Change the code exec($q, $output = array()); to exec($q, $output); . It should work.

Please check exec function details on php.net. The 2nd argument takes a reference to an array. That's what the error messages is telling you. If you want to initialize the $output array, do it on a separate line before passing it to the function.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM