Sorry these are the two additional files that are needed to show whats up.
I think both of these are needed so that the database is set up. But what do i know, it still doesnt work.
setup.php
<?
/*********************************************************
** Modern Red Website **
*********************************************************/
/*########################################################
// MAKE SURE YOU EDIT common.php BEFORE running this file!
//######################################################*/
// setup.php
// Include config file
include('common.php');
// Attempt to connect to database server
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
// If connection failed...
if (!$link) {
// Inform user of error and quit
print "Couldn't connect to database server - Did you edit the common.php properly?";
exit;
}
// Attempt to create database
print "Attempting to create database $dbName <br>\n";
if(!@mysql_create_db($dbName)) {
// Inform user of error
print "# Couldn't create database <br>\n";
} else {
// Inform user of success
print "# Database created successfully <br>\n";
}
// Attempt to select database
print "Attempting to select database $dbName <br>\n";
if(!@mysql_select_db($dbName)) {
// Inform user of error and exit
print "# Couldn't select database <br>\n";
exit;
} else {
// Inform user of success
print "# Database selected successfully <br>\n";
}
print "Attempting to create tables<br>\n";
// Attempt to create tour table
$query = "CREATE TABLE tour (
tourID INTEGER AUTO_INCREMENT PRIMARY KEY,
dates VARCHAR(100),
location VARCHAR(100),
posted INTEGER,
venue MEDIUMTEXT)";
$query = "INSERT INTO tour (tourID, dates, location, posted, venue) VALUES (1, 'Sample Tour', 'Dec 20th - 23rd', 1070296156, 'This is a sample Tour Post to show this items functionality.')";
$result = @mysql_query($query);
if (!$result) {
// Inform user of error
print "# Error creating tour table<br>\n";
print mysql_error();
} else {
// Inform user of euccess
print "# tour table created<br>\n";
}
// Attempt to create news table
$query = "CREATE TABLE news (
newsID INTEGER AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100),
author VARCHAR(30),
posted INTEGER,
body MEDIUMTEXT)";
$query = "INSERT INTO news (newsID, title, author, posted, body) VALUES (1, 'Sample News', 'XISNET', 1070296156, 'This is a sample News Post to show this items functionality.')";
$result = @mysql_query($query);
if (!$result) {
// Inform user of error
print "# Error creating news table<br>\n";
print mysql_error();
} else {
// Inform user of euccess
print "# news table created<br>\n";
}
print "End of setup";
?>
common.php
<?
/*********************************************************
** Modern Red Website **
*********************************************************/
// common.php
// Database details
$dbHost = "";
$dbUser = "";
$dbPass = "";
$dbName = "";
// Common functions
/*********************************************************
** Function: dbconnect() **
** Desc: Perform database server connection and **
** database selection operations **
*********************************************************/
function dbConnect() {
// Access global variables
global $dbHost;
global $dbUser;
global $dbPass;
global $dbName;
// Attempt to connect to database server
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
// If connection failed...
if (!$link) {
// Inform Flash of error and quit
fail("Couldn't connect to database server");
}
// Attempt to select our database. If failed...
if (!@mysql_select_db($dbName)) {
// Inform Flash of error and quit
fail("Couldn't find database $dbName");
}
return $link;
}
/*********************************************************
** Function: fail() **
** Params: $errorMsg - Custom error information **
** Desc: Report error information back to Flash **
** movie and exit the script. **
*********************************************************/
function fail($errorMsg) {
// URL-Encode error message
$errorMsg = urlencode($errorMsg);
// Output error information and exit
print "&result=Fail&errormsg=$errorMsg";
exit;
}
/*********************************************************
** Function: auth() **
** Params: $username - Name of user to authenticate **
** $password - Passwd of user to authenticate **
** Desc: Authenticates a given user. Involves a **
** check that the given username and passwd **
** exists in users table. **
*********************************************************/
function auth($username, $password) {
$crypt = md5($password);
$query = "SELECT userID FROM forumUsers WHERE username = '$username' AND password = '$crypt'";
// Execute the query
$result = mysql_query($query);
// If we found a match...
if (mysql_num_rows($result) == 1) {
// Extract user ID from the results
$user = mysql_fetch_array($result);
$userID = $user['userID'];
} else {
// Otherwise set username to -1
$userID = -1;
}
// Return user ID
return $userID;
}
function checkEmail($email)
{
// Define regular expression
$regexp = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (eregi($regexp, $email)) {
return true;
}
else
{
return false;
}
}
?>