Okay i think i have a script thats supposed to run a mysql restore command in shell but it doesn't work i wanted it to be able to pick the file run gzip on it then run the mysql restore command in shell but it wont work
Heres my script
<HTML>
<TITLE>Mysql Restore</TITLE>
<CENTER><B><FONT SIZE=32>Mysql Restore</FONT></B></CENTER>
<CENTER><FORM METHOD=post ACTION="">
<INPUT type="file" name="filename">
</FORM></CENTER>
<?php
$backupFile = filename
$command = "mysql -user -password database | gzip > $backupFile";
system($command);
?>
</HTML>
Thats the entire script if some one could possibly tell me what im doning wrong, or maybe fix the script for me i would be ever so greatful
Thanks!
Mysql restore php commands
Moderator: General Moderators
Always put your code in php blocks - it makes it much easier to read:
- Line 10 needs quotes and a ;
- I think your shell command is wrong. 1st - is $backupFile gzipped? If so, I think you need to unzip it in a separate command. 2nd - the flags you send to mysql are wrong. You need to actually pass the username and password if you want to do it all in one line. 3rd - your bracket is wrong, it should be <, not >:
There may be a way to put the gunzip command in with the mysql command, but I'm not sure - this should work nonetheless.
Code: Select all
<HTML>
<TITLE>Mysql Restore</TITLE>
<CENTER><B><FONT SIZE=32>Mysql Restore</FONT></B></CENTER>
<CENTER><FORM METHOD=post ACTION="e;"e;>
<INPUT type="e;file"e; name="e;filename"e;>
</FORM></CENTER>
<?php
$backupFile = filename
$command = "e;mysql -user -password database | gzip > $backupFile"e;;
system($command);
?>
</HTML>- I think your shell command is wrong. 1st - is $backupFile gzipped? If so, I think you need to unzip it in a separate command. 2nd - the flags you send to mysql are wrong. You need to actually pass the username and password if you want to do it all in one line. 3rd - your bracket is wrong, it should be <, not >:
Code: Select all
gunzip $backupFile; mysql -u example_user -pexample_password example_database < $backupFile_name_when_unzippedReal programmers don't comment their code. If it was hard to write, it should be hard to understand.