MySQL Dump To Database

Started on the old forum in June 2009 · view the original in the archive · old links redirect here

No replies · 906 views · started 17 years ago · 1 min read

blackhowk Senior · 411 posts #1
  1. // open the some.sql file
  2. $fp = @fopen("some.sql", "r");
  3. $file = fread($fp, 80000);
  4. fclose($fp);
  5. $lines = explode(';', $file);
  6. $cnt = count($lines);
  7. // database connection
  8. mysql_connect("localhost","root","pass");
  9. for($j=0; ($j<$cnt-1); $j ) {
  10. if(!mysql_query($lines[$j])) {
  11. echo "error on line $j of query: ";
  12. echo $lines[$j]." ";
  13. die;
  14. }
  15. }
  16. echo "done";

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close