note 39149 deleted from function.mysql-query by mazzanet

From: Date: Sun, 02 Oct 2005 13:48:45 +0000
Subject: note 39149 deleted from function.mysql-query by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-96186@lists.php.net to get a copy of this message
Note Submitter: klync- ---- I couldn't use mysql_query() to initialize a database the way you can dump a file in from the command line (i.e. mysql -u db_user -p my_database < dbfile.sql). in the end, I had to read the file into a string: $dbf_handle = fopen($db_file, "r"); $sql_query = fread($dbf_handle, filesize($db_file)); fclose($dbf_handle); and then I used explode to go through each line of the dumpfile: foreach ( explode(";", "$sql_query") as $sql_line) { if ( $dbquery = mysql_query("$sql_line") ) { .... Great for a db installer script.

« previous php.notes (#96186) next »