Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    842
    Thanks
    15
    Thanked 9 Times in 9 Posts

    MySQL Query PHP Problems

    How come this doesn't want to work:

    PHP Code:
    $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='".$team."' AND visitingteam='".$team."' ORDER BY gamenumber"); 

    However this does?

    PHP Code:
    $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='".$team."' ORDER BY gamenumber"); 
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #2
    New Coder
    Join Date
    Jun 2004
    Location
    Lyon
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by dniwebdesign
    How come this doesn't want to work:

    PHP Code:
    $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='".$team."' AND visitingteam='".$team."' ORDER BY gamenumber"); 

    However this does?

    PHP Code:
    $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='".$team."' ORDER BY gamenumber"); 
    what do you mean by "doesn't want to work" ??
    is there a parse error? a mysql error?? or ist the result of the query empty (which is most likely the case) ??

    please always post the exact error message tnx

  • #3
    New Coder
    Join Date
    Sep 2002
    Location
    UK
    Posts
    65
    Thanks
    1
    Thanked 0 Times in 0 Posts
    you do realise you don't need to concatenate a string when you are using double quotes don't you?

    PHP Code:
     $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='$team' ORDER BY gamenumber"); 
    The SQL is fine though its in the correct places all i think is that your selecting an incorrect column

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by dniwebdesign
    How come this doesn't want to work:

    PHP Code:
    $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='".$team."' AND visitingteam='".$team."' ORDER BY gamenumber"); 

    However this does?

    PHP Code:
    $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='".$team."' ORDER BY gamenumber"); 
    Must be quite a funny game, where both the home and the visitingteam are the same. So there are probably no records where these are the same.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    842
    Thanks
    15
    Thanked 9 Times in 9 Posts
    Well raf, once again you come back with your smart alleck remarks... thanks.


    instead of AND I belive I should be using OR... thanks again.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #7
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    842
    Thanks
    15
    Thanked 9 Times in 9 Posts

    Unhappy

    Well, sorry to bother you but this query

    PHP Code:
        $result mysql_query("SELECT * FROM hockeystats_schedule WHERE hometeam='$teams' OR visitingteam='$teams' ORDER BY gamenumber"); 
    only returns the one game where the hometeam is right. I have two rows one game has the home team as Capitals and one the visiting the Capitals. It just returns the homegame and not the visiting games. Why?
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #8
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    1. Make sure that you are absolutely sure that there are other records with that value in one of the 2 columns;
    2. Run the query directly inside a db-front like phpmyadmin or so and check the returned rows
    3. Check your recordsetprocessing : do you have a correct loop to proces all rows?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #9
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    842
    Thanks
    15
    Thanked 9 Times in 9 Posts
    nm, I think i might have found the problem
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •