<?php
$connect = mysql_connect("moo","moo","moo");
mysql_select_db("moo",$connect);
$query = mysql_query("SELECT username FROM users WHERE username = '" . $username . "'");
$query2 = mysql_query("SELECT basename FROM users WHERE basename= '" . $basename . "'");
$query3 = mysql_query("SELECT commandername FROM users WHERE commandername = '" . $commandername . "'");
if($query && mysql_num_rows($query) > 0)
{
echo "Username taken!";
}
elseif($query2 && mysql_num_rows($query2) > 0)
{
echo "Basename taken!";
}
elseif($query3 && mysql_num_rows($query3) > 0)
{
echo "Commander name taken!";
}
else
{
mysql_query("INSERT INTO users(username,password,email,fname,lname,basename,commandername,location) VALUES('$username','$password','$email','$fname','$lname','$basename','$commandername','$location')");
echo "Successful!";
//Creates tables and inserts stuff
MySQL_select_db("moo") or die("Could not select database");
$bank = "CREATE TABLE BANK (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($bank);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BANK(id,username) VALUES('$id,$username')");
$brig = "CREATE TABLE BRIG (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($brig);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BRIG(id,username) VALUES('$id,$username')");
$buildings = "CREATE TABLE BUILDINGS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($buildings);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BUILDINGS(id,username) VALUES('$id,$username')");
$cix = "CREATE TABLE CIX (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($cix);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO cix(id,username) VALUES('$id,$username')");
$comms = "CREATE TABLE COMMS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($comms);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO COMMS(id,username) VALUES('$id,$username')");
$fleet = "CREATE TABLE FLEET (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($fleet);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO FLEET(id,username) VALUES('$id,$username')");
$funds = "CREATE TABLE FUNDS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($funds);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO FUNDS(id,username) VALUES('$id,$username')");
$playersnews = "CREATE TABLE PLAYERSNEWS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($playersnews);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO PLAYERSNEWS(id,username) VALUES('$id,$username')");
$brig = "CREATE TABLE VESSELPROCESS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($vesselprocess);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO VESSELPROCESS(id,username) VALUES('$id,$username')");
}
?>
you can see what i'm trying to do.....
..where is the error?mysql_query($bank);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BANK(id,username) VALUES('$id,$username')");
you can't get $id and $username from a query, you have to fetch them first.
also you can combine those quesries into 1
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
if you query the same table then ther eis no need to make more than 1 query.
mysql_query("SELECT id,username FROM users");
you still have to fetch the results.
also
$brig = "CREATE TABLE VESSELPROCESS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($vesselprocess);
that won't create anything.
do all your creates first than query. the way you have it it will make mysql work that much harder. but it should work none the less
$connect = mysql_connect("moo","moo","moo");
mysql_select_db("moo",$connect);
$query = mysql_query("SELECT username FROM users WHERE username = '" . $username . "'");
$query2 = mysql_query("SELECT basename FROM users WHERE basename= '" . $basename . "'");
$query3 = mysql_query("SELECT commandername FROM users WHERE commandername = '" . $commandername . "'");
if($query && mysql_num_rows($query) > 0)
{
echo "Username taken!";
}
elseif($query2 && mysql_num_rows($query2) > 0)
{
echo "Basename taken!";
}
elseif($query3 && mysql_num_rows($query3) > 0)
{
echo "Commander name taken!";
}
else
{
mysql_query("INSERT INTO users(username,password,email,fname,lname,basename,commandername,location) VALUES('$username','$password','$email','$fname','$lname','$basename','$commandername','$location')");
echo "Successful!";
//Creates tables and inserts stuff
MySQL_select_db("moo") or die("Could not select database");
$bank = "CREATE TABLE BANK (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($bank);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BANK(id,username) VALUES('$id,$username')");
$brig = "CREATE TABLE BRIG (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($brig);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BRIG(id,username) VALUES('$id,$username')");
$buildings = "CREATE TABLE BUILDINGS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($buildings);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BUILDINGS(id,username) VALUES('$id,$username')");
$cix = "CREATE TABLE CIX (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($cix);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO cix(id,username) VALUES('$id,$username')");
$comms = "CREATE TABLE COMMS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($comms);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO COMMS(id,username) VALUES('$id,$username')");
$fleet = "CREATE TABLE FLEET (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($fleet);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO FLEET(id,username) VALUES('$id,$username')");
$funds = "CREATE TABLE FUNDS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($funds);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO FUNDS(id,username) VALUES('$id,$username')");
$playersnews = "CREATE TABLE PLAYERSNEWS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($playersnews);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO PLAYERSNEWS(id,username) VALUES('$id,$username')");
$brig = "CREATE TABLE VESSELPROCESS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($vesselprocess);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO VESSELPROCESS(id,username) VALUES('$id,$username')");
}
?>
you can see what i'm trying to do.....
..where is the error?mysql_query($bank);
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
mysql_query("INSERT INTO BANK(id,username) VALUES('$id,$username')");
you can't get $id and $username from a query, you have to fetch them first.
also you can combine those quesries into 1
mysql_query("SELECT id FROM users");
mysql_query("SELECT username FROM users");
if you query the same table then ther eis no need to make more than 1 query.
mysql_query("SELECT id,username FROM users");
you still have to fetch the results.
also
$brig = "CREATE TABLE VESSELPROCESS (
ID INT(3) NOT NULL PRIMARY KEY AUTO_INCREMENT,
USERNAME VARCHAR(20) NOT NULL";
mysql_query($vesselprocess);
that won't create anything.
do all your creates first than query. the way you have it it will make mysql work that much harder. but it should work none the less