Results 1 to 3 of 3

Thread: Query Question

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Query Question

    Ok, I am trying to query my database and limit the results, here is the query I am using:
    PHP Code:
    mysql_query("SELECT * FROM `teams` WHERE approved = 'yes' ORDER BY name ASC LIMIT $cur$maxTeams") or die ("Error Getting Teams! \n<br />\n" .mysql_error()); 
    I can find nothing wrong with this, but it keeps throwing this error at me:
    Code:
    Error Getting Teams!
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    The near " at line one isn't really helpful at all. I am getting frustrated because it just doesn't seem like there is anything that can be wrong. I would greatly appreciate it if someone could send an idea my way. Thanks
    Thanks DD, you saved me countless times

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You may want to make sure that the variables $cur and $maxTeams are getting a value assigned to them. Probably the best way to do this is by echoing them after they are supposed to be assigned.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Or, you might want to try:
    Code:
    mysql_query("SELECT * FROM `teams` WHERE approved = 'yes' ORDER BY name ASC LIMIT ".$cur.", ".$maxTeams) or die ("Error Getting Teams! \n<br />\n" .mysql_error());
    - Mike

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
  •