Jump to content

import .sql


Imaulle

Recommended Posts

Hello,

 

I'm having trouble with the following code  :shrug:

 

$file = file_get_contents("database.sql");

$queries = explode(";",$file);

for ($i=0,$c=count($queries);$i<$c;$i++){
mysql_query($queries[$i],$mlink);
}

 

the problem is the sql file I'm trying to import has ; alllll over the place, not just at the end of the queries, so the queries are not getting inputted correctly. I could see a way to fix this if each query was on a single line, but some of them are over 100 lines each.

 

 

How do I make sure it only explodes using the ; at the end of query? and not the ; that are actually in the tables etc.

 

 

 

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/211855-import-sql/
Share on other sites

all of the .sql files are phpMyAdmin dumps, so I assume all of the queries end with ; and then a line break ?

 

 

this script is for doing a setup of a website, that I gotta install very very many times. I basically upload a zip file, an sql file, and a php file. I then run the php file which will unzip the website, make the sql db, user, add permissions and then a few other things related to the website files.

 

I want to stay out of cPanel, this way is muuuuuuuuch faster

Link to comment
https://forums.phpfreaks.com/topic/211855-import-sql/#findComment-1104294
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.