SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    stamford
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL newbie dilema

    $date = date("Y-m-d");

    // Load up the MySQL Config file
    include("xchange.cfg");

    //Try to connect to database
    mysql_connect("$dbhost","$db","$db")
    or die("Unable to connect to SQL server!");
    @mysql_select_db("$db")
    or die("Unable to select database!");

    //Get the URL to send the person to from the User database
    $RESULT = mysql_query("SELECT * from $userdatabasetable where acct=\"$acct\"");
    $row = mysql_fetch_array($RESULT);
    $URL = $row['URL'];

    //Load up the account's record from the MySql tabel
    $result = mysql_query("SELECT * from $table where acct=\"$acct\" and date=\"$date\" ");

    //If the record doesn't exist
    if(!mysql_num_rows($result)) {


    //Check if new record for today should be created, if true then create one
    If ($date != $recorddate)
    {
    mysql_query("INSERT into $table (DATE, ACCT) VALUES ('$date','$acct')");
    $result = mysql_query("SELECT * from $table where acct=\"$acct\" and date=\"$date\" ");
    }
    }

    //Otherwise just gather what you need.
    else{
    $row = mysql_fetch_array($result);
    $lastipout = $row['LASTIPOUT'];
    $unqiueout = $row['UNQIUEOUT'];
    $hitsout = $row['HITSOUT'];
    $recorddate = $date['DATE'];
    }

    //Add a regular hit out to the record
    //Add one more regular hit out to the current amount of regular hits
    $hitsout++;
    mysql_query("update $table set HITSOUT=\"$hitsout\" WHERE acct=\"$acct\" and date=\"$date\" ");

    //Check if we should add a unique hit out to the record
    //Check to see if the IP address of the user has changed first
    if ($REMOTE_ADDR != $lastipout) {

    //Add 1 more unqiue hit to the current amount of Uniques
    $uniqueout++;
    //Replace the IP on record with the current IP and adds a unqiue hit
    #mysql_query("update $table set LASTIPOUT=\"$REMOTE_ADDR\" and set UNIQUEOUT=\"$uniqueout\" WHERE acct=\"$acct\" and date=\"$date\" ");
    #Old Code -
    mysql_query("update $table set UNIQUEOUT=\"$uniqueout\", LASTIPOUT=\"$REMOTE_ADDR\" where acct=\"$acct\" and date=\"$date\" ");
    }

    header("Location: $URL");

    ?>


    this is the whole script to the thing i want to add on my website, where do I put in my MySQL information and can I make this script work with a countdown ? Please respond soon and if u can, AIM me at DBallerz, thanx in advance with your posts

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DBallerz
    ... where do I put in my MySQL information ...
    Somewhere in the file xchange.cfg?

    // Load up the MySQL Config file
    include("xchange.cfg" );

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, is it a good idea to name the config file xchange.cfg?
    I would add a ".php" at the end (or change the http server config to process .cfg as php), otherwise it's possible for people to request the cfg file and read the mysql username, password etc


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •