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…..
@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.
@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 ??
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 --
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');
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.