1

I made this MySQL query to sum a column then i did echo $rake and i got the output : Resource id #13

It will be highly appreciated if anyone can assist me with this

<?php 
        $rake = mysql_query("select sum(value) as RakeSum from rakeitems");

        echo $rake;

?>

Did i forget something after the query? I am not very good at mysql so im unsure. Any help will be nice :) I have tried changing the query up.

And what does as do in the query, "as RakeSum" what does that mean?

4
  • as RakeSum means that when you go to see the data, it's column name will be RakeSum. otherwise the name would be sum(value) as the column. You can run this in the mysql database to see (with and without as) Commented Dec 11, 2016 at 8:36
  • Ok thanks could yo fix the resource id #13 output im getting? Commented Dec 11, 2016 at 8:39
  • 1
    It's a resource, meaning you need to run it through mysql_fetch_assoc see: stackoverflow.com/questions/7785401/… Commented Dec 11, 2016 at 8:40
  • It sounds like you are just learning php/mysql, then dont' waste time on mysql_* dangerous and removed in php 7. Learn PDO Commented Dec 11, 2016 at 9:00

1 Answer 1

0

Here $rake is a resource
give a look here to know how to use mysql_fetch_assoc to get data from a resource

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.