Current location: Hot Scripts Forums » Programming Languages » PHP » HELP - Execute sql file with php script


HELP - Execute sql file with php script

Reply
  #1 (permalink)  
Old 04-26-07, 07:04 PM
alex11 alex11 is offline
New Member
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
HELP - Execute sql file with php script

I need help to execute myfile.sql directly from a php web page in order to update a database.

The sql file is stored in the same server as the web page. Is it possible to be done with a php script?

Thanks
Alex
Reply With Quote
  #2 (permalink)  
Old 04-26-07, 08:17 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
phpMyAdmin should make this easy for you.
__________________
"BTW, I can't program at all the only thing I figured out is how to upload templates to my server."
Reply With Quote
  #3 (permalink)  
Old 04-28-07, 03:26 PM
alex11 alex11 is offline
New Member
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
more...

I know phpMyAdmin can do it but I need a web page were the user ( who knows nothing about mysql or databases) just need to press ok and the script must execute de query.

i.e.: Populate databaseX with file somefile.sql which is saved in the same server.
Reply With Quote
  #4 (permalink)  
Old 04-28-07, 03:46 PM
alex11 alex11 is offline
New Member
 
Join Date: Apr 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Found solution!

Hi Nova912

Found this script that I think it does what I was looking for.

http://homework.nwsnet.de/products/46

Many thanks for your help
Reply With Quote
  #5 (permalink)  
Old 04-29-07, 02:29 AM
fyrestrtr fyrestrtr is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 191
Thanks: 0
Thanked 0 Times in 0 Posts
Assuming you have the proper rights to run commands on the system, you can use the following:

PHP Code:

exec('/path/to/mysql -u username -pPassword databasename < /path/to/filename.sql'); 

Note the following:

1. Anyone that has access to view the process list will be able to see your database password.

2. You need exec privileges enabled for PHP on your server to make this work.
__________________
Find me at WHT
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for File Management Script (PHP) Guybrush Script Requests 0 03-05-07 06:19 AM
how can call .exe(executable file) via or using php script on web server mohit Script Requests 0 08-03-06 01:59 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 07:29 AM
Run PHP Script Within PHP Script Reg PHP 1 06-29-04 09:09 AM


All times are GMT -5. The time now is 06:01 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.