When you export a mysql file with PhpMyAdmin how do you make a php script read the file and excecute it? This means with all the formatting added by PhpMyAdmin like new lines between different fields of a database.
It depends on how you exported it and what you need to do: if it's exported as MySQL you can just feed it to another phpMyAdmin, give it directly to the mysql client or import it in a PHP script and execute a query with it. If it's a comma delimited file you can read it with 'file()' or 'file_get_contents()' and then parse it
As mentioned above you'll need to explain more on what it looks like.. but it would be much more efficient to just pop it in another PHPMyAdmin and import it.. or if you have shell access type the following: mysql -uuser -ppassword database < mysqldump.sql Code (markup):
The default dump format is simply to output a series of SQL commands that, when executed by MySQL, recreate the database from scratch.
The dump file looks like this That's just an example but the way I did it interpreted each line as it's own command so it tried to excecute the blank lines, username text, email text ) and the other lines as if they were they're own seperate commands. Btw I'm making a software that needs to read it that's why I don't just use phpmyadmin to re-upload the database.
maratz.com/blog/archives/2005/06/05/send-database-backup-to-your-mailbox-with-backup2mail/ Use your imagination and add the http & www stuff above as I cannot post live links yet. Here is a handy program (not mine) that will allow you to hit a page and get the sql dump sent to you. I have been using this for about a year, it's being pushed by windows scheduler since I do not have access to cron on my shared server. I just have my homepages set to the backup2db folder of each of my sites in an infrequently used browser (ie7) that launches (by scheduler) once daily. The end result is that I have gmail backups incase of emergency. These dumps are properly formatted and can just be entered in the SQL section of phpmyadmin. You can restore to a previous state in a few mouseclicks and a wee bit of typing.
That's not what I'm trying to do, I'm trying to make a php script that will automaticaly read the dump file and load it into the mysql database.
Gotcha, restore database . . . not backup How about this post about daniel15.com/blog/2006/12/09/restore-mysql-dump-using-php/ restoring MySql dump I used it along with my backup created with the other program I posted and it worked out fine. hope this helps