Thread: Adding to multiplied values

Adding to multiplied values

From
Reed Loefgren
Date:
All

I've been hacking away on a little time billing database and I've been having
difficulty adding to a calculated amount. This is what I am trying to get
to in an insert (for the column 'grandTotal'):

($compRate * $time) + $expenses

I've tried various combinations of quotes, double quotes, parentheses and
what have you, but I still get errors like:

ERROR:  operator is not unique: "unknown" + "unknown"
and
ERROR:  invalid input syntax for type numeric: "7.50 * 5"

I've been able to figure out hours times comp to produce a subtotal, but I
can't seem to pull in an additional amount to produce the grand total.

What's the syntax here?


thanks,

r

Re: Adding to multiplied values

From
Volkan YAZICI
Date:
On May 18 10:45, Reed Loefgren wrote:
> I've been hacking away on a little time billing database and I've been
> having difficulty adding to a calculated amount.

Can we see the exact PHP code stands for the execution of related query?


Regards.

Re: Adding to multiplied values

From
Reed Loefgren
Date:
On Fri, 19 May 2006, Volkan YAZICI wrote:

> On May 18 10:45, Reed Loefgren wrote:
>> I've been hacking away on a little time billing database and I've been
>> having difficulty adding to a calculated amount.
>
> Can we see the exact PHP code stands for the execution of related query?
>
>
> Regards.
>
>

Sure, and thanks. This query works, but I fail at tying in $totalExpenses
to create a $grandTotal. (pine is gonna butcher this...);

         $query = "INSERT INTO invoices2 (idate, iperiod, inum, ijobcode,
iaccount, icomp, itime, isub, create_time) VALUES('" . $invoiceDate . "',
'" . $billingPeriod . "', '" . $invoiceNumber . "', '" . $jobCode . "', '"
. $accountNumber . "', '" . $billingRate . "', '" . $totalHours . "', '" .
$billingRate * $totalHours . "', 'now()')";


r

Re: Adding to multiplied values

From
"Randy Moller"
Date:
Well, can we see the code that's failing? There's nothing we can tell you
about code that works.....(other than it would be a bit tidier not to do
your math inside a query....)

Z-

-----Original Message-----
From: pgsql-php-owner@postgresql.org [mailto:pgsql-php-owner@postgresql.org]
On Behalf Of Reed Loefgren
Sent: Friday, May 19, 2006 7:13 AM
To: Volkan YAZICI
Cc: PHP on postgresql list server
Subject: Re: [PHP] Adding to multiplied values

On Fri, 19 May 2006, Volkan YAZICI wrote:

> On May 18 10:45, Reed Loefgren wrote:
>> I've been hacking away on a little time billing database and I've been
>> having difficulty adding to a calculated amount.
>
> Can we see the exact PHP code stands for the execution of related query?
>
>
> Regards.
>
>

Sure, and thanks. This query works, but I fail at tying in $totalExpenses
to create a $grandTotal. (pine is gonna butcher this...);

         $query = "INSERT INTO invoices2 (idate, iperiod, inum, ijobcode,
iaccount, icomp, itime, isub, create_time) VALUES('" . $invoiceDate . "',
'" . $billingPeriod . "', '" . $invoiceNumber . "', '" . $jobCode . "', '"
. $accountNumber . "', '" . $billingRate . "', '" . $totalHours . "', '" .
$billingRate * $totalHours . "', 'now()')";


r

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.6.0/342 - Release Date: 5/17/2006