Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Sep 25, 2005, 20:58   #1
FCouples
SitePoint Member
 
Join Date: Sep 2005
Posts: 18
Execute an SQL file

Hey everyone I have an SQL file I would like to execute, is there any easy way of doing this without using

system("mysql -uUsername -pPassword dbname < file.sql");

Basically it's a whole bunch of this:

Code:
DROP TABLE IF EXISTS downloads;
CREATE TABLE downloads (
  teacherid bigint(100) NOT NULL default '0',
  url varchar(255) NOT NULL default '',
  title varchar(255) NOT NULL default '',
  visible char(1) NOT NULL default '1',
  section varchar(50) default 'General',
  path varchar(255) NOT NULL default ''
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `homeworkapr`
#

DROP TABLE IF EXISTS homeworkapr;
CREATE TABLE homeworkapr (
  teacherid bigint(20) NOT NULL default '0',
  period char(3) NOT NULL default '',
  d1 text,
  d2 text,
  d3 text,
  d4 text,
  d5 text,
  d6 text,
  d7 text,
  d8 text,
  d9 text,
  d10 text,
  d11 text,
  d12 text,
  d13 text,
  d14 text,
  d15 text,
  d16 text,
  d17 text,
  d18 text,
  d19 text,
  d20 text,
  d21 text,
  d22 text,
  d23 text,
  d24 text,
  d25 text,
  d26 text,
  d27 text,
  d28 text,
  d29 text,
  d30 text,
  d31 text
) TYPE=MyISAM;
# --------------------------------------------------------
Thanks!

- Jeff
FCouples is offline   Reply With Quote
Old Sep 26, 2005, 03:11   #2
chrisranjana
Web development Company
 
chrisranjana's Avatar
 
Join Date: Jan 2001
Location: chennai , tamil nadu , India
Posts: 710
If you have PHPmyadmin installed in your server, you could upload this sql file too.
chrisranjana is offline   Reply With Quote
Old Sep 26, 2005, 03:18   #3
spikeZ
dooby dooby doo
silver trophybronze trophy
 
spikeZ's Avatar
 
Join Date: Aug 2004
Location: Manchester UK
Posts: 11,240
You can just put it into a mysql_query().
PHP Code:

$sql=mysql_query("

CREATE TABLE downloads (
  teacherid bigint(100) NOT NULL default '0',
  url varchar(255) NOT NULL default '',
  title varchar(255) NOT NULL default '',
  visible char(1) NOT NULL default '1',
  section varchar(50) default 'General',
  path varchar(255) NOT NULL default ''
) TYPE=MyISAM;
"
) or die(mysql_error());
Mike
spikeZ is offline   Reply With Quote
Old Sep 26, 2005, 03:24   #4
rain5017
SitePoint Zealot
 
rain5017's Avatar
 
Join Date: Sep 2005
Posts: 166
phpMyAdmin

I like it
rain5017 is offline   Reply With Quote
Old Sep 26, 2005, 03:37   #5
ruchit
SitePoint Addict
 
ruchit's Avatar
 
Join Date: Sep 2005
Location: miDDle oF NoWHere
Posts: 222
you can also use SQLYog... google for sqlyog download for the latest version
ruchit is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

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 On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 21:37.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved