1

I follow this and it working well in Window

But when i run in ubuntu (13.10) and using xampp

<?php
$server     = "localhost";
$username   = "root";
$password   = "root";
$db = "test";
$restore_file   = "/home/myname/test.sql";
$cmd = "/opt/lampp/bin/mysql -h {$server} -u {$username} -p{$password} {$db} < $restore_file";
//umask(0);
exec($cmd);
echo "Restore complete!";
?>

it echo restore complete but database is empty. If i run script on terminal then it working.

How to fix that thanks

7
  • try without curly brace in your $cmd Commented Mar 8, 2014 at 16:32
  • @Sadik it must be running because restore complete that show on browser Commented Mar 8, 2014 at 16:32
  • echo $cmd;what is the O/P? Commented Mar 8, 2014 at 16:33
  • output is /opt/lampp/bin/mysql -h localhost -u root -proot test < /home/myname/test.sql Commented Mar 8, 2014 at 16:36
  • can u execute that command directly in shell? Commented Mar 8, 2014 at 16:37

1 Answer 1

0

What is O/P?

<?php
        if(function_exists('exec')) {
        echo "exec function is enabled";
        }
        else {
        echo "exec is not enabled";
        }
  ?>

Edit
Execute this command in shell.

chmod +x /opt/lampp/bin/mysql

Edit

exec($cmd, $output, $return); 

echo $output;
if (!$return) {
    echo "Success";
} else {
    echo "Failed";
}
Sign up to request clarification or add additional context in comments.

3 Comments

output is exec function is enabled
maybe its a permission issue.
what are $output and $return variable?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.