I keep getting theis error when i run the script related to a string in my config.php file that adds a prefix to the tables during and after installation.
ERROR:Parse error: syntax error, unexpected T_STRING in /fpgs/fpgshttpd/mbecerra/game/install.php on line 47
The line it is referencing is:
$sql = 'CREATE TABLE + $DATABASE_INFO['table_prefix'] + users(
install.php
<?php
//include the file config.php in this script
include("config.php");
//include the function utilities file function.php
include("functions.php");
//connect to the MYSQL Server
$connection = mysql_connect($DB_INFO['hostname'], $DB_INFO['username'], $DB_INFO['password']) or die("Failed to connect to the MYSQL Server");
//open the database
mysql_select_db($DB_INFO['database']) or die("Could not open database");
//check to see if the user table was already installed
if (table_exists($DB_INFO['table_prefix'] + "users", $DB_INFO['database'])) {
//if the users table was already installed let the user know
print "Users Table Already Exists. Aborting Installation";
//and abort the installation
exit;
}
//check to see if the characters table was already installed
if (table_exists($DB_INFO['table_prefix'] + "invites", $DB_INFO['database'])) {
//if the characters table was already installed let the user know
print "Characters Table Already Exists. Aborting Installation";
//and abort the installation
exit;
}
//create the sql statement that will create the table called Users with 5 fields
// member_id as an integer that can not be null , is the primary key and auto increments
// username as varchar with 16 length
// password as varchar with 16 length
// e-mail as varchar with 64 length
// securitykey as varchar with 32 length
$sql = 'CREATE TABLE + $DATABASE_INFO['table_prefix'] + users(
member_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
username varchar( 16 ),
password varchar( 16 ),
email varchar( 64 ),
securitykey varchar( 32 )
) type=MyISAM';
//check to see if it worked
$result = mysql_query($sql,$connection) or die(mysql_error());
//If something went wrong
If (!$result){
//we want to let the user know the install failed since the Users table couldn't be created
print "Install Failed because the Users tables could not be createrd.<br> Please check your mysql setting in config.php and try again.";
//Otherwise the Users table were created
} else {
//so we want to let the user know the Users table was created successfully
print "Users table was created successfully<br>";
}
//create the sql statement that will create the table called Characters with 4 fields
// id as an integer that can not be null , is the primary key and auto increments
// charactername as varchar with 16 length
// hp as integer
// strength as integer
// gold as integer
$sql = 'CREATE TABLE $DB_INFO[\'table_prefix\']invites(
id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
hp int,
strength int,
gold as int
) type=MyISAM';
//check to see if it worked
$result = mysql_query($sql,$connection) or die(mysql_error());
//If something went wrong
If (!$result){
//we want to let the user know the install failed since the characters table couldn't be created
print "Install Failed because the characters tables could not be createrd.<br> Please check your mysql setting in config.php and try again.";
//Otherwise the characters table were created
} else {
//so we want to let the user know the characters table was created successfully
print "characters table was created successfully<br>";
}
print "The Multiplayer Server Database Was Installed Successfully"
?>
Config.php
<?php
// MySQL Server hostname or IP address
$DB_INFO['hostname'] = "bleep";
// MySQL Database Username
$DB_INFO['username'] = "bleep";
// MySQL Database Password
$DB_INFO['password'] = "bleep";
// MySQL Database Name
$DB_INFO['database'] = "bba_game";
// Table Prefix
$DB_INFO['table_prefix'] = "bba_";
?>
Functions.php
<?php
function table_exists ($table, $db) {
$tables = mysql_list_tables ($db);
while (list ($temp) = mysql_fetch_array ($tables)) {
if ($temp == $table) {
return TRUE;
}
}
return FALSE;
}
?>