Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create MySql DB from file .sql

Status
Not open for further replies.

Palmke

Programmer
May 12, 2004
16
IT
hey guys,

i have php running on phpmyadmin,
I made a database in mysql and I exported it in a .sql file.

this is what's happening now :

whenever I run the php files which access the db in mysql,
on a machine server (phpmyadmin) for the first time,
unless I manually create the db or browse manually the .sql file from phpmyadmin in the db, of course the php files don't find my db.

So I'd want that if PHP doesn't find the db,
1) creates the DB
2) creates the tables
3) input all entries

best from my .sql file.


I searched online but didn't find any help,
maybe i'm tired today ;)
I'd appreciate any suggestion!

My idea as far as now :
copy and paste any instruction from the .sql file and run them only one by one with mysql_query() but it's really tedious and I don't even know if I have time!
 
You could use [blue]fopen()[/blue] to get the contents of a file into a variable that you can then send to the db via [blue]mysql_query()[/blue]

But you would have to issue a query first to check for the existance of the DB you are looking for.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top