SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2000
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello everybody.
    I created a MySQL database and PHP script following Keith Reichley's article on SitePoint entitled, "Jump Start to Easy URL's." Everything works fine. However, when I add some code that "updates" a column called totalclicks, it doesn't work. The code is below:
    PHP Code:
    <?
    $connection 
    mysql_connect(localhostuser, ****) or die("Couldn't connect.");

    $db_name "justforwebmasters_com";
    $table_name "redirects";
    $pathstring getenv("HTTP_HOST") == "justforwebmasters.com" 
    getenv("PATH_INFO") : $PHP_SELF ;

    $id $id;

    $db mysql_select_db($db_name$connection)
    or die(
    "Couldn't select database.");

    $sql "SELECT id, address, totalclicks FROM $table_name UPDATE redirects SET totalclicks=totalclicks+1 ".
              
    "WHERE id=$id";

    $result mysql_query($sql,$connection) or die("Error: <font color=red>$sql</font>");

    while (
    $row = @mysql_fetch_array($result))       {
    $id $row["id"];
    $address $row["address"];
    $totalclicks $row["totalclicks"];
    }

    print 
    "<HTML><HEAD>\n";
    print 
    "<META http-equiv=\"Refresh\" content=\"0; URL=\"".$address."\"\n";
    print 
    "<BODY>\n";
    print 
    "Click <A href=\"".$address."\">here</A> to continue.\n";
    print 
    "</BODY>\n";
    print 
    "</HTML>\n";
    ?>
    Kevin Yank tried to help me out, but it didn't work that well. Any help would be greatly appreciated.
    Last edited by JustForWebmasters; Apr 16, 2001 at 18:58.
    Corbb O'Connor
    Looking for quality website design or database programming?
    Contact me for more information and a FREE quote!

  2. #2
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why dont you try to seperate your sql query first?
    Fetch the url
    Update recorf


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
  •