Jump to content

why aint this working?


seany123

Recommended Posts

$rcount = $db->execute("SELECT SUM(quantity) as'' FROM items WHERE player_id = '$player->id'");

$rcount is likely to be a resource (a database result) rather than an actual integer value. You need to read your value from the result set.

 

Why as''?

 

because if not i get this echo'd "SUM(quantity) 153 "

 

try echoing $rcount before you perform the math.

 

   echo $rcount; // for testing purposes
   $num = 250;
   $count = ($num - $rcount);
   
   echo $rcount;
   echo "<br>";
   echo $count;
   

 

That just did nothing different.

what does this give you:

 

$rcount = $db->execute("SELECT SUM(quantity) AS `count` FROM `items` WHERE `player_id` = '".$player->id."'");
   echo $rcount->count;

 

that gave me no echo from $rcount.

Link to comment
Share on other sites

Okay so because nobody has been able to help me with this maybe if i ask i different question i might find more joy....

 

does anyone know how to add up all the values in a table.. example...

 

$query = $db->execute("SELECT quantity FROM items WHERE player_id='$player->id'")

$rcount = (all quantitys added together).

 

there is already this but its not allowing me to use it in a equation...

 

$rcount = $db->execute("SELECT SUM(quantity) AS `` FROM `items` WHERE `player_id` = '".$player->id."'");

 

Link to comment
Share on other sites

listen dude .. this is a free forum (free for you to seek help/advice), and the people with whom you seek advice, are volunteering their time/efforts/advice.  volunteering means, work for free.

 

so, there are several reasons why nobody is helping you.

 

1. your problem does not interest anybody.

2. you have no retainer on anybody, nor do you employ anybody here .. therefore, nobody ahs an obligation to help you.

3. perhaps you've just annoyed people by having made the last 6 posts in your own thread.  now it's a spite thing?

 

anyways, firing out an indirect threat as so, "anyone know any other forum where i can get some help?", might have worked on ones' mom as a child, but i don't believe that will raise any concern around here.

 

most of these guys know their stuff, and if asked nicely, they will help you.  if nobody responds to your thread(s), refer to points 1, 2, and 3 again.

 

and if you want something done sooooooo badly, perhaps coughing up a few buckos will spark some interest.  but as long as you're seeking free help, you have to be more patient than that. seriously.

 

$db->execute();

 

will return true on success, and false on fail.  so, right off the bat, you are going to get unexpected results as you have it.

 

regardless, you are setting SUM(quantity) AS ``  .. you cannot get the SUM of anything if you set its alias to nothing.

 

i'm assuming you're using ADODB?  i'm not familiar with it, but you can try this:

 

$rcount = $db->GetAll("SELECT SUM(`quantity`) AS `count` FROM `items` WHERE `player_id` = '".$player->id."'");

echo $rcount['count'];

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.