In addition to Paul's suggestion of using mysql_error to check to see if it was successful, when I'm having trouble I like to print the query in the output for testing and then try to run the query from the MySQL CLI.
print "SELECT SUM(s.groundballs) AS grounders FROM stats s LEFT JOIN rahs r ON s.name = r.name WHERE (s.position ='$position');"; I've found that this helps to see what I'm trying to have MySQL do. Steve On Wed, Mar 27, 2002 at 09:53:33PM -0600, 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')"); > > while($number=mysql_fetch_array($numberquery)){ > printf ("Total groundballs for $position: %s</font></td>",$number["grounders"]); > } > > Thanks! > -------------------------------------------- > -Alex "Big Al" Behrens > E-mail: [EMAIL PROTECTED] > Urgent E-mail: [EMAIL PROTECTED] (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: > [EMAIL PROTECTED] > ----- Original Message ----- > From: "Paul DuBois" <[EMAIL PROTECTED]> > To: "Alex Behrens" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > 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: [EMAIL PROTECTED] > > >Urgent E-mail: [EMAIL PROTECTED] (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: > > >[EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > 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 <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- 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 <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php