This read me file is for the SQL Installer script by JimmyHarmon.com and nwa.cc
PHP Auto SQL Script installer is © 2005 - 2006 Jimmy Harmon, http://www.jimmyharmon.com and Nwa.cc, http://www.nwa.cc
  If you need help, please visit our board  here.
 
PHP Auto SQL Script Installer
V3.2.7
 
You should have a basic understanding of SQL before using this script. You should at least know how to create a SQL database before attempting to use this script.
 
If you do not know how to create a SQL database, that's ok, you can use a template that's been created for you that would automatically create the database if you were to use the upload feature in phpmyadmin. This is a common way of adding databases in phpmyadmin.
 
 
Usage
In order to use the PHP sqlinstaller, upload the included files to your server. They will be ready to use immediately. You may want to configure the .css file to your own liking. Point your browser to http://www.yourdomain.com/directory/install.html and you'll find the form to fill out.
 
*Note - Your visitors will not see the SQL database information being installed on their sql server, so make sure you know what you're doing by testing the database that's being created yourself. It was installed successfully on several of our websites, so we know it works for us. The object is to create your database, test it and test it again. Once your visitor starts to use your sqlinstaller, they will have successfully installed your sql script on their sql server.
 
 
Creating the SQL Database
This is what the tables will look like once they are created. This is pretty standard stuff for someone who knows how to create sql tables. This is the information that will be submitted via the sqlinstaller form. If created correctly (by you) then an Sql database will be created and completely installed through your form. This is the sample database that I have created for you. None of these values will work unless you have a php script that goes along with it.
 
 
$crt1="CREATE TABLE members (
  id int(11) NOT NULL,
  name varchar(64) default NULL,
  companyname varchar(64) default NULL,
  email varchar(128) default NULL,
  address varchar(128) default NULL,
  county varchar(28) default NULL,
  postcode varchar(28) default NULL,
  tel varchar(28) default NULL,
  fax varchar(28) default NULL,
  heardaboutusfrom varchar(28) default NULL,
  their_username varchar(64) default NULL,
  their_password varchar(64) default NULL,
  comments text,
  activated tinyint(1) NOT NULL default '0',
  activated_date int(11),
  PRIMARY KEY (id),
  KEY activated (activated),
  KEY activated_date (activated_date),
  KEY their_username (their_username)) TYPE=MyISAM";
 
$crt2="CREATE TABLE admin (
  id int(11) NOT NULL,
  their_username varchar(64) default NULL,
  their_password varchar(64) default NULL,
  contact_email varchar(64) default NULL,
  auto_activate tinyint(1) NOT NULL default '0',
  PRIMARY KEY (id)) TYPE=MyISAM";
 
$md5_password = md5($dbpass);
$crt3="INSERT INTO `admin` VALUES ('1', '$email', '$md5_password', '$email', '0')";
 
$crt4="CREATE TABLE logins (
  id int(11) NOT NULL auto_increment,
  login_date int(11) NOT NULL default '0',
  member_id int(11) default NULL,
  ip_no varchar(32) default NULL,
  user_agent varchar(250) default NULL,
  PRIMARY KEY  (id),
  KEY login_date (login_date)
  ) TYPE=MyISAM";
 
$crt5 ="CREATE TABLE blocked_ranges (
  total tinyint(4) NOT NULL auto_increment,
  range varchar(7) default NULL,
  PRIMARY KEY  (total),
  UNIQUE KEY range (range)) TYPE=MyISAM";
 
$crt6 ="CREATE TABLE blocked_ips (
  total int(11) NOT NULL auto_increment,
  ip varchar(16) default NULL,
  PRIMARY KEY  (total),
  UNIQUE KEY ip (ip)) TYPE=MyISAM";
 
$crt7 ="CREATE TABLE blocked_psi (
  total int(11) NOT NULL auto_increment,
  ip varchar(16) default NULL,
  PRIMARY KEY  (total),
  UNIQUE KEY ip (ip)) TYPE=MyISAM";
 
 
Custom Error Messages for Each Table Created
 
You will need to create a separate line for each table being created. It will look like this:
 
mysql_query("drop table if exists members");
mysql_query("drop table if exists admin");
mysql_query("drop table if exists logins");
mysql_query("drop table if exists blocked_ranges");
mysql_query("drop table if exists blocked_ips");
mysql_query("drop table if exists blocked_psi");
echo "Attempting to create new tables... ";
$error_text="<h2>There has been a problem creating the required tables, and/or inserting data (error message: ";
 
 
Additional Error Messages
 
This will be for specific error messages. For instance, if a table already exists, you would not be able to create it. Most likely this wont happen as you should tell whomever uses your SQL Installer that they should create a separate database specifically for the database that you are installing for them. The additional error messages should be in this format:
 
if ( !mysql_query($crt1) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt1;
 exit;
}
if ( !mysql_query($crt2) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt2;
 exit;
}
if ( !mysql_query($crt3) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt3;
 exit;
}
if ( !mysql_query($crt4) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt4;
 exit;
}
if ( !mysql_query($crt5) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt5;
 exit;
}
if ( !mysql_query($crt6) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt6;
 exit;
}
if ( !mysql_query($crt7) )
{
 echo $error_text.mysql_error()."). $go_back";
 echo $crt7;
 exit;
}
 
So, as you can tell, there's some work to be done on your part. The main PHP program will be well worth it once it's set up.
 
If you need additional help, don't hesitate to send me an e-mail at jim@nwa.cc and I'll be more than happy to help with the initial set up. I'm also creating a message board specifically for this topic.
 
This program is © Jimmy Harmon and http://www.jimmyharmon.com - http://www.nwa.cc