Mysql Dump using PHP -


i trying write function returns whole dump of sql using code:

$command = "c:\\program files\\mysql\\mysql server 5.6\\bin\\mysqldump --add-drop-table --host=$hostname     --user=$username "; if ($password)          $command.= "--password=". $password ." ";  $command.= $dbname; var_dump(terminal($command));  function terminal($cmd) {     if (function_exists('system'))     {         ob_start();         system($cmd, $retval);         $output = ob_get_contents();         ob_end_clean();         $function_used = "system";     }     else if(function_exists('passthru'))     {         ob_start();         passthru($cmd, $retval);         $output = ob_get_contents();         ob_end_clean();         $function_used = "passthru";     }     else if(function_exists('exec'))     {         exec($cmd, $output, $retval);         $output = implode("n", $output);         $function_used = "exec";     }     else if(function_exists('shell_exec'))     {         $output = shell_exec($cmd);         $function_used = "shell_exec";     }     else      {         $output = "cannot execute shell commands";         $retval = 1;     }      return array('output' => $output, 'returnvalue' => $retval, 'functionused' => $function_used); } 

the database credentials correct when run command in normal command line desired result.

the problem when try using these command, either function use empty string output. on other hand return value 1 results true think , means function executed correctly otherwise false return value.

for example use 'system' fist encounter. corrent how getting output?

regards

since have spaces in path executable, need enclose in double-quotes.

$command = "\"c:\\program files\\mysql\\mysql server 5.6\\bin\\mysqldump\" --add-drop-table --host=$hostname --user=$username "; 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -