Order By ? loval vs hosting

Discussion in 'MySQL' started by Megafu, Jun 23, 2007.

  1. #1
    ok this is going to sound weird but here it goes ... i have make a script (PHP + MYSQL) that works just fine locale:

    SELECT name , id FROM gallery WHERE parent = '$parentID' and published = '1' ORDER BY 'name' ASC

    localle everything works fine with results like:
    Album
    Car
    Zoe

    i upload the same script to the server i have and magic ... it is not sorted by name but by 'id' ...

    what the hell is going on?


    any help is apreciated. :confused: :(
     
    Megafu, Jun 23, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this:
    SELECT 
      name,
      id
    FROM 
      gallery 
    WHERE 
      parent = '$parentID' 
    and 
      published = '1' 
    ORDER BY 
      name 
    ASC
    Code (markup):
    you were passing "name" as a string into the ORDER BY statement. By default mysql will sort your table by id, that's why you got that on your website. I have no idea though why it worked on localhost
     
    UnrealEd, Jun 24, 2007 IP
  3. Megafu

    Megafu Peon

    Messages:
    133
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks so much for your help . :)

    yep no idea why it worked on local host . anyway . its working just fin . thanks again . ;)
     
    Megafu, Jun 24, 2007 IP