If Else $Get check

Discussion in 'PHP' started by bkflash, Nov 9, 2006.

  1. #1
    Hey im having a problem figuring out how to do this with php. What iam trying to do is $game=$_GET['game']; the file from the URL bar and then i want it to check the mysql database to see if that game actually exists, i don't want people inserting random names to my url bar, and if it doesn't exists i want it to print out somthing like "that file or game doesn't exist on the server". Anybody have an idea of how to make this happen?
     
    bkflash, Nov 9, 2006 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    
    $game = $_GET['game'];
    
    $result = mysql_query("SELECT * FROM games WHERE game_title = '" . mysql_real_escape_string($game) . "'");
    
    if(mysql_num_rows($result))
    {
      // do whatever you have to do...
    }
    else
    {
      echo "That file or game doesn't exist on the server";
    }
    
    PHP:
     
    SoKickIt, Nov 9, 2006 IP
  3. bkflash

    bkflash Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks sokickit, i will try that
     
    bkflash, Nov 10, 2006 IP