Gossamer Forum
Quote Reply
Huh?
Can anyone see a problem with this query!

UPDATE advertiser_info SET CreditLeft = CreditLeft - 0.01, HitsReceived = HitsReceived + 1 WHERE PrimaryID = 4

No error is produced by mysql_error(), and other parts of the query are updated fine (such as (HitsReceived), but CreditLeft does not seem to get deducted!

This is in PHP BTW Tongue (relating to the mysql_error())

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Huh? In reply to
Cut and paste it into MySQL and see if CreditLeft is updated. If it is, then there's something wrong with how you are passing in the query, or the php code that is generating the query.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Huh? In reply to
I run this query via PHPMyAdmin, and it said 1 row was affected;

UPDATE advertiser_info SET CreditLeft = CreditLeft - 0.01, HitsReceived = HitsReceived + 1 WHERE PrimaryID = 9


However, looking at CreditLeft for the appropriate ID, it still remains on 9999! Crazy

Could it be the database is corrupt? Unsure

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Huh? In reply to
Try:

UPDATE advertiser_info SET CreditLeft = CreditLeft - 1, HitsReceived = HitsReceived + 1 WHERE PrimaryID = 9
Quote Reply
Re: [Paul] Huh? In reply to
Eugh...turned out to be simpler than that.

In the database, I was using credits, in the form of 1234 (which would be $12.34). When doing the update, I was minusing 0.01. I got around it be using sprintf to make sure it was a 2 digit decimal, and then timesing by 100 to make it a round number Tongue Seems to be working ok now :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!