Any one see a problem with this ?

Discussion in 'PHP/MySql' started by Adam H, Oct 10, 2009.

Remove these ads by signing in
Remove these ads by signing in
Thread Status:
Not open for further replies.
  1. Adam H Administrator

    Member Since:
    Jan 7, 2008
    Message Count:
    2,807
    Likes Received:
    162
    Occupation:
    Web Developer
    Location:
    Norfolk Uk
    Ive been working with these files for 5 hours today, ive got nearly all of them sorted but this one is killing me

    Im getting this error :

    Code (text):

    Notice: Undefined index: id in /home/bretr/public_html/freehostout.php on line 4
    This is the code :

    PHP:
    <?php
    error_reporting (E_ALL);
    require_once ("./includes/config.php");
    $hostid = $_GET['id'];
    $getfreehosthits = "SELECT Hits, HostingURL FROM freehosting WHERE HostingId='". $hostid ."'";
    $freehosthitsrs = mysql_query($getfreehosthits, $conn) or die (mysql_errno() . ": " . mysql_error()). "\n";
    while($freehosthits = mysql_fetch_array($freehosthitsrs))
    {
        $hits = $freehostinghits['Hits'];
        $url = $freehostinghits['HostingURL'];
        $newhits = $hits + 1;
        $updatehits = mysql_query("UPDATE freehosting SET Hits='". $newhits."' WHERE HostingId='". $hostid ."'");
        mysql_query($updatehits, $conn);
    }
    mysql_free_result($freehosthitsrs);
    mysql_close($conn);
    header("Location:". $url. "");
    exit();
    ?>
     
    Any ideas ?
  2. SeoKungFu Active Member

    Member Since:
    Jul 10, 2009
    Message Count:
    603
    Likes Received:
    77
    Occupation:
    SEO Ninja
    if( isset ( $_GET['id' )) {
    $hostid = intval( $_GET['id'] );
    }

    Even better - make the isset cover all the query down bellow.
    And use _at_ _least_ intval if not harder, tighter check to stop'em crooks pwning your site !
  3. Adam H Administrator

    Member Since:
    Jan 7, 2008
    Message Count:
    2,807
    Likes Received:
    162
    Occupation:
    Web Developer
    Location:
    Norfolk Uk
    Thanks bud , got it sorted in the end. All is working , site is nearly ready to go
  4. Orion New Member

    Member Since:
    Sep 29, 2009
    Message Count:
    969
    Likes Received:
    25
    Location:
    http://admin-spot.com
    Can't wait till the sites ready!
Thread Status:
Not open for further replies.

Share This Page