mysql query

Discussion in 'MySQL' started by Alffy, Feb 3, 2008.

  1. #1
    Hi there,

    I am working on my first database site, so far so goo but i am having some problems getting it to display properly...

    e.g.

    http://www.mysite.com/index.php?team=0033

    will show the team information

    but

    http://www.mysite.com/index2345.php?team=fulham wont

    I have the row set to:

    team varchar(255) utf8_general_ci Yes NULL

    should it be something else so letters as well as numbers can be used?

    :confused:
     
    Alffy, Feb 3, 2008 IP
  2. tures

    tures Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please post your query
     
    tures, Feb 3, 2008 IP
  3. guestonline

    guestonline Banned

    Messages:
    669
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    post your query here,i will help you
     
    guestonline, Feb 3, 2008 IP
  4. Alffy

    Alffy Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys,

    The query looks like:

    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");

    // $id = $_SERVER['PHP_SELF'];
    $query = "SELECT * FROM football WHERE team = ".$_GET['team'];
    $result=mysql_query($query);

    $num=mysql_numrows($result);
    mysql_close();

    I am pretty su re this is something simple
     
    Alffy, Feb 4, 2008 IP
  5. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #5

    I would do it more like this:

    
    
    if ($go_team){
    $team=$_POST['team'];
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    // $id = $_SERVER['PHP_SELF'];
    $query = "SELECT * FROM football WHERE team like '$team'";
    $result=mysql_query($query);
    while ($row = mysql_fetch_array($result){
    echo "Team Selected: $team";
    }
    $num=mysql_numrows($result);
    echo "Total teams displayed:  $num";
    mysql_close()
    }
    
    <form method="post">
    Type team:<br>
    <input type="text" name="team" value="<?= $team ?>">
    <input type="submit" name="go_team">
    </form>
    
    PHP:

    Now you are looking for an match (case insensitive) on the team your typing...
     
    LittleJonSupportSite, Feb 4, 2008 IP
  6. Alffy

    Alffy Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for the offers of help guys and to littlejon for giving me some code to play with.

    Managed to fix this by simply changing the sql statement to:

    $query = "SELECT * FROM football WHERE team = '".$_GET['team']."'";
     
    Alffy, Feb 4, 2008 IP
  7. dvrtmcc

    dvrtmcc Well-Known Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    113
    #7
    I am not much familliar with mysql database. I have 10 MB mysql size hosting. What happens when it gets full?
     
    dvrtmcc, Feb 5, 2008 IP