CREATE DATABASE
Posted: Sun Jun 05, 2005 2:49 pm
I am trying to use code to create a mysql database and some tables in it.
I have 2 files
File 1:
File 2:
It doesnt come up with any errors but I looked on my PHPMYADMIN and there are no entries. Any Suggestions 
I have 2 files
File 1:
Code: Select all
<?php
$user="user";
$password="password";
$database="users";
mysql_connect("localhost",$user,$password);
mysql_query("CREATE DATABASE $database");
mysql_close();
?>Code: Select all
<?php
$user="user";
$password="password";
$database="users";
mysql_connect("localhost",$user,$password);
mysql_select_db($database)or die( "Unable to select database");
mysql_query("CREATE TABLE users (username varchar(40),password varchar(50),regdate varchar(20),email varchar(100),character varchar(2),PRIMARY KEY (username))");
mysql_query("CREATE TABLE stats (username varchar(40),character int(2) DEFAULT '01' NOT NULL,health int(3) DEFAULT '100' NOT NULL,money int(100) DEFAULT '2000' NOT NULL,rank int(3) DEFAULT '01' NOT NULL,level int(2) DEFAULT '001' NOT NULL,respect int(3) DEFAULT '001' NOT NULL,house int(2) DEFAULT '01',cstat int(2) DEFAULT '01' NOT NULL,gstat int(3) DEFAULT '001' NOT NULL,status int(1) DEFAULT '1' NOT NULL,jail int(1) DEFAULT '0' NOT NULL,gtatime NOT NULL,crimetime NOT NULL,octime NOT NULL,jailtime NOT NULL,PRIMARY KEY (username))");
mysql_close();
?>