Jump to content

Unable to sum MySQL columns


acemiller6

Recommended Posts

From the MySQL prompt I can run the sum function no problem.

 

SELECT sum(apples) FROM kitchen;

 

and this will total the number of apples in the \"apples\" column of the kitchen db. That is working for me no problem. However, when I try to do that from my php code, its not working.

 

$temp = mysql_query(\"SELECT sum(apples) FROM kitchen\", $db);

echo \"Total apples: \". $temp;

 

It prints out to my browser:

 

Total apples: Resource ID #3

 

I know the database is open and it works because if I just try and look at one entry into the database with a select statement it works. So what I am doing wrong? Any help would be much appreciated.

Thanks.

 

Ace

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.