Mysql Table Creator

By Shadow_Slayerz on Jan 29, 2005

Easier way to make mysql tables

Call This sql_connect.php 

<?php

$db_url = "host";
$db_name = "Database Name";
$db_username = "username";
$db_password = "password";

mysql_connect( $db_url, $db_username, $db_password );
mysql_select_db( $db_name );

?>

Call This Run.php.  Edit The "Example" with your table Names and run this file to create your tables.

<?php

include ("sql_connect.php");

$create = "CREATE TABLE user (
id int(10) NOT NULL auto_increment,
example4 varchar(25) NOT NULL default '',
example3 varchar(250) NOT NULL default '',
example2 varchar(25) NOT NULL default '',
example1 varchar(250) NOT NULL default '',
PRIMARY KEY (id)
);";

mysql_query($create)
or die ("Could not create tables because ".mysql_error());
echo "Complete.";
?>

Comments

Sign in to comment.
F*U*R*B*Y*   -  Apr 19, 2006

whatca could do is, run it like a form, asking what is the name instead of example, and so on and forth. just an idea. thats how i\'ve edit mine to :p

 Respond  
log2   -  Mar 09, 2005

Not a bad script, but it can be bad... You should only run it yourself and never bu another person... so in other words it should only be in an admin centre, and never on a normal page or you\'ll have a ton of MySQL databases

 Respond  
Hawkee   -  Jan 31, 2005

This can be good for making portable code, but just make sure to keep your run.php file up to date as you alter your tables.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.