Jump to content

nephsuperman

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by nephsuperman

  1. 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;

    }

    }

    ?>

     

     

  2. I have agreed to create a website for a band. They know nothing about computer shtuff and I want to make it to where they themselves can add the news and the tour dates and such. So, for some reason I bought a template flash site that gives you all of this, the problem is that they do not tell you how to change the code to get it to work on your server.

     

    I have already changed the $dbhost, $dbUser, $dbPass, $dbName to the correct server information.

     

    A flash addnews.swf is used to get the information and it is passed into addnews.php. The flash file runs down the php code in addnews, and it states this error. "Couldn't add news item."

     

    Here is the code for addnews.php the server info is removed from the pasted file.

     

    Thanks

     

    <?

    /*********************************************************

    ** Modern Red Website **

    *********************************************************/

    // Define Database connection details

    $dbHost = "";

    $dbUser = "";

    $dbPass = "";

    $dbName = "";

    $table = "news";

     

    // Check username and password

    if ($username != "modern" || $password != "modern2003") {

    print "&result=Fail";

    print "&errorMsg=" . urlencode("Incorrect username and/or password");

    exit;

    }

     

     

    // Attempt to connect to MySQL server

    $link = @mysql_connect($dbHost, $dbUser, $dbPass);

     

    // If the connection was unsuccessful...

    if (!$link)

    {

    // Report error to Flash and exit

    print "&result=Fail";

    print "&errorMsg=" . urlencode("Could not connect to server");

    exit;

    }

     

    // Attempt to connect to MySQL server

    $link = @mysql_connect($dbHost, $dbUser, $dbPass);

     

    // If the connection was unsuccessful...

    if (!$link)

    {

    // Report error to Flash and exit

    print "&result=Fail";

    print "&errorMsg=" . urlencode("Could not connect to database");

    exit;

    }

     

    // Attempt to select database. If unsuccessfull...

    if (!@mysql_select_db($dbName))

    {

    // Report error to Flash and exit

    print "&result=Fail";

    print "&errorMsg=" . urlencode("Could not select $dbName database");

    exit;

    }

     

    // Fetch the current time

    $posted = time();

     

    // Build Query

    $query = "INSERT INTO news (title, author, body, posted)

    VALUES('$newsTitle', '$newsAuthor', '$newsBody', $posted)";

     

    // Execute Query

    $result = @mysql_query($query);

     

    // If query was successful

    if ($result)

    {

    // Report success back to Flash movie

    print "&result=Okay";

    }

    else

    {

    // Otherwise, tell Flash we fucked up

    print "&result=Fail";

    print "&errorMsg=" . urlencode("Couldn't add news item");

    }

     

    // Close the connection

    mysql_close($link);

     

    ?>

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.