Jump to content

Recommended Posts

         
         $stock_count_attrib1=$db->sp("attrib_stock1"); 
 $stock_count_attrib2=($db->sp("attrib_stock2"));

          $total_stock_count = ($stock_count_attrib1+$stock_count_attrib2);

 echo $total_stock_count ;

 

Outputs: 22180

 

Value of: attrib_stock1 = 22

Value of: attrib_stock2 = 18

 

I thought the output should be: 40?

 

Please help.

 

Please excuse my newbieness trying to learn...

 

Yes it's exactly like that, It seems to be concatening the two values and adding a zero rather than adding them?

$stock_count_attrib1=$db->sp("attrib_stock1"); 
 	  $stock_count_attrib2=($db->sp("attrib_stock2"));

          $total_stock_count = ($stock_count_attrib1+$stock_count_attrib2);

 echo $total_stock_count ;

This is pasted from the page. and the results are: 22180

The only way you'd get a result like that is if $db->sp() is echoing the value, not returning it.

 

If that is the case, it would echo 22, then 18, then your echo $total_stock_count would echo 0 because the other variables would have no value and nothing+nothing=0. 

 

Since it would all get echoed right next to each other it'd produce your 22180 number.

 

A quick way to check that would be to:

$stock_count_attrib1=$db->sp("attrib_stock1"); 
echo "<br>--<br>";
$stock_count_attrib2=($db->sp("attrib_stock2"));
echo "<br>--<br>";

$total_stock_count = ($stock_count_attrib1+$stock_count_attrib2);

echo $total_stock_count ;

 

Those extra echo's would break up the number and you'd get output like:

22
--
18
--
0

Yes your absolutely correct.

 

I thought: $db->sp("attrib_stock2") was the value from the database, but it does echo... I don't suppose anybody can break down this: $db->sp("attrib_stock2") to explain further?

 

Thanks very much for your help.

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.