Jump to content

Very simple adding not working !


duckstar

Recommended Posts

Hi there, for some reason thoe following isn't working at all.. Anyone know why ?

		
$temp1 = $nonRBProducts[$counteri][3];
$temp1 * 1;
$temp2 = $RBProducts[$counterr][3];
$temp2 * 1;
$temp3 = $temp1 + $temp2;

$temp1  = 9

$temp2 = 4

$temp3 = ""

 

Anyone know why ?

 

Cheers

Link to comment
Share on other sites

uhhmm

This displays the correct values:

<?php
$temp1=9;
$temp2=4;
//$temp1 = $nonRBProducts[$counteri][3];
$temp1 * 1;
//$temp2 = $RBProducts[$counterr][3];
$temp2 *  1;
$temp3 = $temp1 + $temp2;

echo"temp1 = $temp1<br />temp2 = $temp2<br />temp3 = $temp3<br />";
?>

 

Are you sure the variables $nonRBProducts[$counteri][3]; and $RBProducts[$counterr][3]; contain a value?

 

And what is the purpose of attempting to multiplying by 1? If that's what you want to do because $temp2 *  1; wont do anything!

Link to comment
Share on other sites

Well first of all, what are you doing in the commented lines below?

 

		
$temp1 = $nonRBProducts[$counteri][3];
$temp1 * 1; ///<--- What are you doing here?  This won't result in the value of $temp1 changing in any way.
$temp2 = $RBProducts[$counterr][3];
$temp2 * 1; ///<--- And here?
$temp3 = $temp1 + $temp2;

Link to comment
Share on other sites

Thanks for the replys

die($nonRBProducts[$counteri][3]);

Returns 9

die($RBProducts[$counterr][3]);

Returns 4

 

$temp2 * 1;

I know this doesn't change the value.  I did this to try and force PHP to see it as a INT so that it would add correctly on the next line.

 

die($temp1."+".$temp2."=".$temp3);

Now returns = "9+4=13"

 

but

		$temp1 = $nonRBProducts[$counteri][3];
		$temp1 * 1;
		$temp2 = $RBProducts[$counterr][3];
		$temp2 * 1;
		$temp3 = $temp1 + $temp2;
		//die($temp1."+".$temp2."=".$temp3);
		$mergedAdviceNotes[$mergedIndex][3] = $temp3;
		die($mergedAdviceNotes[$mergedIndex][3]);

This returns nothing...

 

 

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.