backup - How to use mysql dump in php -


I have tried to use the mysql dump in the command line and it works. How do I do this in php? I got this code from the internet, and tried to do it.

  & lt ;? Php ob_start (); $ Username = "root"; $ Password = "mypassword"; Hostname = "localhost"; $ SConnString = mysql_connect ($ hostname, $ user name, $ password) or die ("Unable to connect to MySQL"); $ Connection = mysql_select_db ("test", $ sConnString) or die ("DB could not be selected"); $ Command = "C: \ wamp \ bin \ mysql \ mysql5.1.36 \ bin --add-drop-table --host = $ hostname - Database Testing> C: \ wamp \ www \ test \ tester.sql" ;  

I do not really know what this code means: system ($ command);

  $ dump = ob_get_contents (); Ob_end_clean (); $ Fp = fopen ("dump SQL", "W"); Fputs ($ FP, $ dump); Fclose ($ FP); ? & Gt;  

I have imported the .sql file generated in a database and I get this error from phpmyadmin:

  appears in an error in your SQL query The following is the MySQL server error output, if any, can also help you diagnose the problem error: unknown punctuation string @ 3 STR :: \ sql: e: \ uusrane \ Nrew \ Documents & gt; Set path = C: \ wamp \ bin \ mysql \ mysql5.1.36 \ bin; E: \ User \ Nrew \ Documents & gt; Set Path = C: \ wamp \ bin \ mysql \ mysql5.1.36 \ bin; E: \ User \ Nrew \ Documents & gt; Set Path = C: \ wamp \ bin \ mysql \ mysql5.1.36 \ bin; SQL query: e: \ user \ nrew \ document & gt; Set Path = C: \ wamp \ bin \ mysql \ mysql5.1.36 \ bin; MySQL said: # 1064 - There is an error in your SQL syntax; Closest 'E: \ Users \ Nrew \ Documents & gt; Set Path = C: \ wamp \ bin \ mysql \ mysql5.1.36 \ bin 'Check the manual related to your MySQL server version for the correct syntax to use on line 1  

Please help, I want to learn how to do this in php.

system ($ command); Externally executes the mysqldump command.

I do not really understand the script you stick to, it seems that the mix of two scripts?

However, syntax errors in the dump file probably mean that you have a version mismatch (4.x running on the target server)?

--compatible = mysql40


Comments