isedeasy Posted November 15, 2009 Share Posted November 15, 2009 I have a query that needs to multiple a number of clicks with a constant (defined earlier on) and store it in the row. This is what I have... define ( "PPC", 0.01); mysql_query("UPDATE deals SET earnings=".PPC."*clicks WHERE id='$id'") or die(mysql_error()); The column 'earnings' is a DECIMAL(3,2) When ever this query is ran I get the value 9.99 in the earnings column. I am sure its something simple I am overlooking but its starting to frustrate me. Cheers for any help Quote Link to comment https://forums.phpfreaks.com/topic/181625-solved-help-with-a-query/ Share on other sites More sharing options...
Philip Posted November 15, 2009 Share Posted November 15, 2009 Well what does the column "clicks" have as its value? Quote Link to comment https://forums.phpfreaks.com/topic/181625-solved-help-with-a-query/#findComment-958098 Share on other sites More sharing options...
isedeasy Posted November 15, 2009 Author Share Posted November 15, 2009 int(6) Anything from 0 - 999999 Quote Link to comment https://forums.phpfreaks.com/topic/181625-solved-help-with-a-query/#findComment-958108 Share on other sites More sharing options...
Scorpy Posted November 16, 2009 Share Posted November 16, 2009 DECIMAL columns in MySQL 5.1 do not allow values larger than the range implied by the column definition. For example, a DECIMAL(3,0) column supports a range of -999 to 999. A DECIMAL(M,D) column allows at most M - D digits to the left of the decimal point. This is not compatible with applications relying on older versions of MySQL that allowed storing an extra digit in lieu of a + sign. The above should explain what's happening clearly, to fix just increase your DECIMAL(M,D) to what you need. Quote Link to comment https://forums.phpfreaks.com/topic/181625-solved-help-with-a-query/#findComment-958222 Share on other sites More sharing options...
isedeasy Posted November 16, 2009 Author Share Posted November 16, 2009 OK that makes sense, I thought DECIMAL(3,2) could have a max value of 999.99 not 9.99. I did not realise the 'M' was the total length so to speak. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/181625-solved-help-with-a-query/#findComment-958416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.