List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 28 2002 4:20am
Subject:Re: SELECT frmo two tables
View as plain text  
At 21:53 -0600 3/27/02, Alex Behrens wrote:
>This is the code I'm using and I'm a newbie so this is still a lil
>challenging for me:
>
>$numberquery = mysql_query("SELECT SUM(s.groundballs) AS grounders FROM
>stats s LEFT JOIN rahs r ON s.name = r.name WHERE (s.position =
>'$position')");

As I suspected, you're not checking the result from mysql_query()
to see whether or not it succeeded.  Do so:

if (!$numberquery)
     die ("Query failed, error is: " . mysql_error ());

You're just shooting yourself in the foot and wasting your time if
you don't check for errors.

>
>while($number=mysql_fetch_array($numberquery)){
>   printf ("Total groundballs for $position: 
>%s</font></td>",$number["grounders"]);
>}
>
>Thanks!
>--------------------------------------------
>-Alex "Big Al" Behrens
>E-mail: bigal@stripped
>Urgent E-mail: bigal-cell@stripped (Please be brief!)
>Phone: 651-482-8779
>Cell: 651-329-4187
>Fax: 651-482-1391
>ICQ: 3969599
>Owner of the 3D-Unlimited Network:
>http://www.3d-unlimited.com
>Send News:
>news@stripped
>----- Original Message -----
>From: "Paul DuBois" <paul@stripped>
>To: "Alex Behrens" <bigal@stripped>; <mysql@stripped>
>Sent: Wednesday, March 27, 2002 9:45 PM
>Subject: Re: SELECT frmo two tables
>
>
>>  At 20:14 -0600 3/27/02, Alex Behrens wrote:
>>  >hey guys,
>>  >
>>  >this mysql line doesn't seem to work:
>>  >
>>  >SELECT SUM(s.groundballs) AS grounders FROM stats s LEFT JOIN rahs r ON
>>  >s.name = r.name WHERE (s.position = '$position')
>>  >
>>  >why not? is there somethign wrong with my syntax? it says this error:
>>  >"Supplied argument is not a valid MySQL result resource"
>>
>>  You're leaving out details, namely the surrounding PHP code from within
>>  which you're executing this statement.  My guess is that you didn't
>>  check the result from mysql_query() to see whether or not it succeeeded.
>>  Do so, and if it fails, print the value of mysql_error() to see what it
>>  says.
>>
>>  >
>>  >Thanks!
>>  >--------------------------------------------
>>  >-Alex "Big Al" Behrens
>>  >E-mail: bigal@stripped
>>  >Urgent E-mail: bigal-cell@stripped (Please be brief!)
>>  >Phone: 651-482-8779
>>  >Cell: 651-329-4187
>>  >Fax: 651-482-1391
>>  >ICQ: 3969599
>>  >Owner of the 3D-Unlimited Network:
>>  >http://www.3d-unlimited.com
>>  >Send News:
>>  >news@stripped
>>
>>
>
>>
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <mysql-thread104385@stripped>
>To unsubscribe, e-mail <mysql-unsubscribe-paul=snake.net@stripped>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Thread
SELECT frmo two tablesAlex Behrens28 Mar
  • RE: SELECT frmo two tablesRon Jamison28 Mar
    • Re: SELECT frmo two tablesAlex Behrens28 Mar
      • Re: SELECT frmo two tablesPaul DuBois28 Mar
    • Re: SELECT frmo two tablesMike28 Mar
      • Re: SELECT frmo two tablesMichael Stassen28 Mar
    • Re: SELECT frmo two tablesAlex Behrens28 Mar
      • Re: SELECT frmo two tablesSteve Suehring28 Mar
      • Re: SELECT frmo two tablesPaul DuBois28 Mar
  • Re: SELECT frmo two tablesmike28 Mar