Important alert: (current site time 7/15/2013 10:47:36 AM EDT)
 

article

A stand-alone php/mysql install script. (fixed)

Email
Submitted on: 5/22/2004 2:42:15 PM
By: pileofcrap  
Level: Beginner
User Rating: By 3 Users
Compatibility: PHP 4.0
Views: 14046
(About the author)
 
     I'm still learning php, but I've always wanted to know how to make install scripts for my stuff. Now that I have learned it, I will pass it on :)

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				



Remember, before you judge my code.. keep in mind that IT IS INTENDED FOR NEWBS ;)
Before you just TRY this, make sure you have a mysql database/username/password on hand.
It's quite easy really, here:


<?php
mysql_connect("localhost", "Mysql_Username", "password");
mysql_select_db("Mysql_database");
mysql_query("mysql information goes here");
?>

The purpose of this is for the script to completely run without the need of an include. As long as you know how to run queries for mysql, then youll get the hang of this.

 

Here is an example of a mysql query:
CREATE TABLE Tablename (
userid int(25) NOT NULL auto_increment,
first_name varchar(25) NOT NULL default '',
last_name varchar(25) NOT NULL default '',
) TYPE=MyISAM



Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/24/2004 11:28:39 AMJon Anders

That's not an install script, that is just an example how to query a database.
(If this comment was disrespectful, please report it.)

 
5/29/2004 5:39:25 PM

As Jon said this isn't a "install script", however it is a kinda good example for a person just starting to learn mysql/php so, well done.
(If this comment was disrespectful, please report it.)

 
6/1/2004 8:21:00 AM

I'm not try it yet, sorry I'll try later
(If this comment was disrespectful, please report it.)

 
6/1/2004 11:52:58 AMDan Redding - Blue Knot Software

Well, the sample SQL given creates a table if inserted into the PHP code; maybe that is what he meant by 'install'
(If this comment was disrespectful, please report it.)

 
3/28/2006 5:05:13 PMSh4db01

disappointing
(If this comment was disrespectful, please report it.)

 
5/11/2007 12:47:17 AMpileofcrap

Hey guys,
wow I forgot all about this. basically, what I did with this was make an install.php and call the file. It installed the mysql for me automatically instead of having to go through phpmyadmin and doing it myself.
(If this comment was disrespectful, please report it.)

 
10/6/2008 8:54:45 AMCletus

This is pretty much an install script.... Just a very basic one... It creates a database that is to be used by his application.... Without this script, there would be no database for said application to use.... It makes it so you don't have to use phpMyAdmin to create your database/tables...

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.