SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist elgumbo's Avatar
    Join Date
    Nov 2002
    Location
    North West, UK
    Posts
    545
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL works on the page but chokes the validator !

    Hi

    I ve got my page up and running and everything seems fine when viewed through a browser but when I try and validate the code (using Position Tech's validator) I get an mysql error.

    It doesn't happen on all the sql just on a couple of bits, both of which work fine when pasted into phpMyadmin.

    The code in question is :
    Code:
     
    $ticketlist4 = @mysql_query( "SELECT ParkName, Parkurl FROM TicketsParks WHERE ParkDestination=$did AND ID<>$pid ORDER BY ParkName");
    where $pid and $did are passed in the url.

    and the response from the validator is : Error performing query: You have an error in your SQL syntax near 'AND ID<> ORDER BY ParkName'

    Any ideas what's going on?

    Peter

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    When you validate, are you validating with values for did and pid in the querystring? (I'm not familiar with that validator so I may be completely off-base here).

    Also, is register_globals Off and are you checking that $did and $pid hold valid values before the SQL query gets executed?
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Evangelist elgumbo's Avatar
    Join Date
    Nov 2002
    Location
    North West, UK
    Posts
    545
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Ian

    Both the values are in the query string and I use them both in a previous query which causes no problem with the validator.

    Again, in the browser, there is no problem just in the validator.

    Normally I would just leave it - as far as the client is concerned the page works fine - but I think it is causing problems with search engines. Position tech shows me that Ask cannot crawl that page.

    Peter

  4. #4
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using
    PHP Code:
     
    $ticketlist4 
    mysql_query"SELECT ParkName, Parkurl FROM TicketsParks WHERE (ParkDestination= '$did') AND (ID <> '$pid') ORDER BY ParkName" ); 
    the problem I can see in your error message is that id <> order by ... show that there is no ID being filled in... So there is a problem with $pid..

    Try to echo it before the query to check if it is set and holds the right data..

    Greets,

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by peanuts
    the problem I can see in your error message is that id <> order by ... show that there is no ID being filled in... So there is a problem with $pid..

    Try to echo it before the query to check if it is set and holds the right data..
    That's why I asked the questions that I did. Bear in mind that you may get datatype problems if you use '$pid' etc. on a Numeric datatype field ... the apostrophes are intended only for String and Date datatype values.
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Evangelist elgumbo's Avatar
    Join Date
    Nov 2002
    Location
    North West, UK
    Posts
    545
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Peanuts / Ian

    I put the query in the brackets and quotes and the validator lets it through.

    The id and pid where definately being passed across because the results are echo'd further down the page.

    Anyway, cheers again for all your help - now I've just got to figure out why it's telling me the <tr> tags aren't closed when they are But that's a thread for another board.

    Peter


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
  •