Asked  1 Year ago    Answers:  5   Viewed   11 times

I found a cool MySQL backup script. It's working fine on some hosting companies. Now I'm trying it on a different host running PHP Version 5.2.8.

I have a php.ini file that contains this (in both root dir and current dir):

disable_functions =. 

I'm getting these warnings, and it seems like they are more than warnings. If exec() doesn't run, the database is not backed-up.

Undefined variable: output in /home/nealsent/public_html/backups/backup_dbs.php on line 21
Undefined variable: res in /home/nealsent/public_html/backups/backup_dbs.php on line 210
exec() has been disabled for security reasons in /home/nealsent/public_html/backups/backup_dbs.php on line 210

The code is the following one.

// dump db

    // Line 210:
exec("$MYSQL_PATH/mysqldump $db_auth --opt $db 2>&1 >$BACKUP_TEMP/$db.sql", $output, $res);



Many hosts disable certain functions, and do not allow overriding them in custom php.ini's (just because PHP offers the ability to have a custom php.ini, does not mean that all PHP setups are necessarily configured to allow you to change that option via such).

Chances are that host simply doesn't allow exec() period. Not much you can really do about that.

Thursday, April 1, 2021

Problem solved with the following command:

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("C:wampbinphpphpVERSIONNUMBERphp-win.exe -f C:/wamp/www/path/to/backgroundProcess.php", 0, false);
Thursday, April 1, 2021

Try using the direct path of the application (/usr/bin/unrar of whatever), it sounds like php can't find the application.

Thursday, April 1, 2021

If you are on xampp look below

How to enable curl in xampp?

you should only need to change this php

C:Program Filesxamppphpphp.ini

Thursday, April 1, 2021

If you have access to your php.ini file look for the disable_functions item and remove ini_set from the list. Depending on your server setup you may also need to restart Apache for this to take effect.

If you do not have access to php.ini you will need to ask your Sys Admin or hosting provider to make the change.

Thursday, April 1, 2021
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :