I was trying to create a table within mysql, and when I ran the script, it spit out this error:
Database not selected.
Well, I have checked and checked, and I know it is probably something very simple since I am a newbie to PHP programming. Here is the entire code, could you guys help me figure out what is wrong?
<head>
<title>Create ACT Tables</title>
</head>
<body>
<?php
##############################################################################################
This script connects to the database and creates the tables necessary for the ACT Program
##############################################################################################
######################################################
Set variables for the connection to the database
######################################################
$Host = "mysql.best1-host.com";
$User = "XXXXXXX";
$Password = "XXXXXXXX";
$DBName = "trinity";
$TableName1 = "title1";
$TableName2 = "title2";
$TableName3 = "title3";
$TableName4 = "title4";
$TableName5 = "title5";
$TableName6 = "title6";
$TableName7 = "title7";
$TableName8 = "Act_auth";
#########################
Connect to Database
#########################
$Link = mysql_connect ($Host, $User, $Password);
#######################################
Create Tables for the ACT Program
#######################################
$Query = "CREATE table $TableName1 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName2 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName3 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName4 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName5 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName6 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName7 (section INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, submitted_by INT NOT NULL, title INT NOT NULL, heading TEXT, sub1 TEXT, sub2 TEXT, sub3 TEXT, sub4 TEXT, sub5 TEXT, sub6 TEXT, date TEXT, status NOT NULL INT UNSIGNED)";
$Query = "CREATE table $TableName8 (zone_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, pass TEXT)";
##################################################################################
Check to see if the Query intiated and Created the Tables within the database
##################################################################################
if (mysql_db_query ($DBNAME, $Query, $Link)) {
print ("The Query was a Success!! <br>\n");
}
else {
print ("Failed:".mysql_error ());
}
##################################################
Close the Database Connection and Close HTML
##################################################
mysql_close ($Link);
?>
</body>