Forum Moderators: coopster

Message Too Old, No Replies

add value from a function to a variable

how to do for a newbie, been searching all day

         

phalseid

8:31 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



I have a function

myfunction($ID, price);

and i want to add the result to another number:

this doesnt work:

<? echo myfunction($ID, price) +3?>"

nor does

$totalprice=myfunction($ID, price)
echo $totalprice +3

please help!@

phalseid

dmorison

8:44 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi phalseid,

Code looks fine (except for "price" not being $price) so it is probably down to the return value of myFunction() not being what you think it is.

What does:

echo myFunction($ID,price);

give on its own?

phalseid

9:48 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



>>Code looks fine (except for "price" not being $price)

hmm...

myFunction($ID,$price);
gives no result that I can see

where as

myFunction($ID,price);retuns the price

here is the code from that function that shows the price:

while (!$recordSet->EOF)
{
$field_value = make_db_unsafe ($recordSet->fields[field_value]);
echo $field_value;

$recordSet->MoveNext();
} // end while

>What does:
>echo myFunction($ID,price);

Fatal error: Call to a member function on a non-object

normally, i just call this function and it outputs the value of the field i send to it (alphanumeric). i just want to add a number to the result.