/    Sign up×
Community /Pin to ProfileBookmark

how to create a install.php ?

hi guys,

any idea how to create an install.php file for my php project..where it has n directories within it and i would install database tables and dupmp data…..

is there any software that would do that for me..

thanx for the help..

Regards,

Noor

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@sitehatcheryMay 12.2006 — Not sure if this will help, but I have included the install files for PHPBB. Maybe you could find clues there.

[upl-file uuid=2befb8b2-e19a-463a-9fd9-cb0a2e84075d size=87kB]install.zip[/upl-file]
Copy linkTweet thisAlerts:
@The_Little_GuyMay 12.2006 — If you have PHP MyAdmin, you could download your database, as an sql file, and then save it as a php file, that when run will make your database.
Copy linkTweet thisAlerts:
@nooor83authorMay 12.2006 — do you mean after exporting it into a sql file i should rename the file to .php file and run that php file or what..i didn't get what you meant ?? can you explain more please ??


thanx

Noor
Copy linkTweet thisAlerts:
@The_Little_GuyMay 12.2006 — Yeah.

Just select the database you want, and click on export, select the tables you want, and export it as INSERT, [I]there is a drop down box, make sure it is on INSERT[/I]

Export -- SQL

Compression -- None

[CODE]It will export it as text in PHP MyAdmin and you will get something like this:
-- phpMyAdmin SQL Dump
-- version 2.8.0.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 12, 2006 at 05:50 PM
-- Server version: 4.1.18
-- PHP Version: 4.4.2
--
-- Database: dtoporg_mail
--

-- --------------------------------------------------------

--
-- Table structure for table config
--

CREATE TABLE config (
max_file_size text NOT NULL,
min_file_size text NOT NULL,
hometxt text NOT NULL,
css text NOT NULL,
anonymousup text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table config
--

INSERT INTO config VALUES ('5120', '0', 'Welcome to File Host, where you can get free file hosting.', 'body{rn font-family:verdana,arial;rn}rn.heading{rn text-align:center;rn font-size:20px;rn font-weight:bold;rn}rntable{rn border:solid 1px #000000;rn border-collapse: collapse;rn margin:auto;rn width:50%;rn}rntd{rn border:solid 1px #000000;rn border-collapse: collapse;rn background-color:#FFFFFF;rn text-align:left;rn padding: 5px;rn}rnrnth{rn border:solid 1px #000000;rn border-collapse: collapse;rn font-size:20px;rn font-weight:bold;rn}rn.empty{rn color:#FF0000;rn font-size:10px;rn}', 'No');

-- --------------------------------------------------------

--
-- Table structure for table user
--

CREATE TABLE user (
id bigint(20) NOT NULL auto_increment,
first varchar(25) NOT NULL default '',
last varchar(25) NOT NULL default '',
email varchar(255) NOT NULL default '',
actvalue text NOT NULL,
activated text NOT NULL,
share text NOT NULL,
username varchar(25) NOT NULL default '',
password varchar(25) NOT NULL default '',
download_password varchar(25) NOT NULL default '',
rank char(2) NOT NULL default '2',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table user
--

INSERT INTO user VALUES (1, 'Ryan', 'Naddy', '[email protected]', '9J5HKJWXARA6', '', 'Yes', 'ryan', 'abc123', 'abc123', '1');[/CODE]


But all you need is this:
[CODE]CREATE TABLE config (
max_file_size text NOT NULL,
min_file_size text NOT NULL,
hometxt text NOT NULL,
css text NOT NULL,
anonymousup text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

INSERT INTO config VALUES ('5120', '0', 'Welcome to File Host, where you can get free file hosting.', 'body{rn font-family:verdana,arial;rn}rn.heading{rn text-align:center;rn font-size:20px;rn font-weight:bold;rn}rntable{rn border:solid 1px #000000;rn border-collapse: collapse;rn margin:auto;rn width:50%;rn}rntd{rn border:solid 1px #000000;rn border-collapse: collapse;rn background-color:#FFFFFF;rn text-align:left;rn padding: 5px;rn}rnrnth{rn border:solid 1px #000000;rn border-collapse: collapse;rn font-size:20px;rn font-weight:bold;rn}rn.empty{rn color:#FF0000;rn font-size:10px;rn}', 'No');

CREATE TABLE user (
id bigint(20) NOT NULL auto_increment,
first varchar(25) NOT NULL default '',
last varchar(25) NOT NULL default '',
email varchar(255) NOT NULL default '',
actvalue text NOT NULL,
activated text NOT NULL,
share text NOT NULL,
username varchar(25) NOT NULL default '',
password varchar(25) NOT NULL default '',
download_password varchar(25) NOT NULL default '',
rank char(2) NOT NULL default '2',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

INSERT INTO user VALUES (1, 'Ryan', 'Naddy', '[email protected]', '9J5HKJWXARA6', '', 'Yes', 'ryan', 'abc123', 'abc123', '1');[/CODE]


to modify that, just add this:

$sql = '......';

You can either run those through the PHP MyAdmin, and click on get PHP CODE, or you can do it by hand.

The final result looks something like this:
[code=php]<?php
$dbHost = "localhost";
$dbUser = "User_name";
$dbPass = "password";
$dbDatabase = "database_name";
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");

$sql = 'CREATE TABLE config ('
. ' max_file_size text NOT NULL,'
. ' min_file_size text NOT NULL,'
. ' hometxt text NOT NULL,'
. ' css text NOT NULL,'
. ' anonymousup text NOT NULL'
. ' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;';


$sql = 'INSERT INTO config VALUES ('5120', '0', 'Welcome to File Host, where you can get free file hosting.', 'body{\r\n font-family:verdana,arial;\r\n}\r\n.heading{\r\n text-align:center;\r\n font-size:20px;\r\n font-weight:bold;\r\n}\r\ntable{\r\n border:solid 1px #000000;\r\n border-collapse: collapse;\r\n margin:auto;\r\n width:50%;\r\n}\r\ntd{\r\n border:solid 1px #000000;\r\n border-collapse: collapse;\r\n background-color:#FFFFFF;\r\n text-align:left;\r\n padding: 5px;\r\n}\r\n\r\nth{\r\n border:solid 1px #000000;\r\n border-collapse: collapse;\r\n font-size:20px;\r\n font-weight:bold;\r\n}\r\n.empty{\r\n color:#FF0000;\r\n font-size:10px;\r\n}', 'No');';

$sql = 'CREATE TABLE user ('
. ' id bigint(20) NOT NULL auto_increment,'
. ' first varchar(25) NOT NULL default '','
. ' last varchar(25) NOT NULL default '','
. ' email varchar(255) NOT NULL default '','
. ' actvalue text NOT NULL,'
. ' activated text NOT NULL,'
. ' share text NOT NULL,'
. ' username varchar(25) NOT NULL default '','
. ' password varchar(25) NOT NULL default '','
. ' download_password varchar(25) NOT NULL default '','
. ' rank char(2) NOT NULL default '2','
. ' PRIMARY KEY (id)'
. ' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;';

$sql = 'INSERT INTO user VALUES (1, 'Ryan', 'Naddy', '[email protected]', '9J5HKJWXARA6', '', 'Yes', 'ryan', 'abc123', 'abc123', '1');';
?>[/code]


If you just want to create the tables, and not insert anything, than don't put in the INSERT INTO ......

Also, you can make it just like a normal php doccument.
Copy linkTweet thisAlerts:
@nooor83authorMay 13.2006 — hey little guy,

thanx for the reply

you to run mysql_query($sql) after each $sql...right..


Noor
Copy linkTweet thisAlerts:
@The_Little_GuyMay 14.2006 — Nope, don't need to, atleast I didn't have to.
×

Success!

Help @nooor83 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...