mysql error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • theoni
    New Member
    • Feb 2008
    • 20

    mysql error

    Hello,

    I am trying to do sth for work which doen't work and i am really frustrated.
    the query
    [PHP]$myquery="selec t * from tbl_routes where DAYNAME(rt_Depa rture) AS rt && rt='$weekday' && rt_FK_Destinati on='$dest' && rt_FK_Departure ='$dep' ";[/PHP]

    is supposed to give back the flights which leave on sundays ( rt='$weekday' ) where $weekday='Sunda y' but rt='$weekday' doesn't give me any results. I get a mysql error that mysql_fetch_arr ay is invalid. Any ideas what's wrong about that?

    thank you
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Hi theoni,

    Welcome to TSDN!!!

    It is a good practice to always debug your queries using mysql_error() where
    Originally posted by theoni
    I get a mysql error that mysql_fetch_arr ay is invalid.
    e.g.
    [PHP]mysql_query($qu ery) or die("Error in query: ".mysql_error() );[/PHP]
    You are using alias in WHERE clause which is not allowed and you are doing in the wrong way as well
    Code:
    WHERE DAYNAME(rt_Departure) AS rt
    The correct query is
    [PHP]$myquery="selec t * from tbl_routes where DAYNAME(rt_Depa rture)='$weekda y' && rt_FK_Destinati on='$dest' && rt_FK_Departure ='$dep' ";[/PHP]

    Comment

    • theoni
      New Member
      • Feb 2008
      • 20

      #3
      Originally posted by mwasif
      Hi theoni,

      Welcome to TSDN!!!

      It is a good practice to always debug your queries using mysql_error() where
      e.g.
      [PHP]mysql_query($qu ery) or die("Error in query: ".mysql_error() );[/PHP]
      You are using alias in WHERE clause which is not allowed and you are doing in the wrong way as well
      Code:
      WHERE DAYNAME(rt_Departure) AS rt
      The correct query is
      [PHP]$myquery="selec t * from tbl_routes where DAYNAME(rt_Depa rture)='$weekda y' && rt_FK_Destinati on='$dest' && rt_FK_Departure ='$dep' ";[/PHP]

      Thank you very much for the help mwasif, it worked! :) Have a nice day!

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        Glad to help you.

        Comment

        Working...