cheyner Posted May 2, 2007 Share Posted May 2, 2007 I am trying to insert a negative number in my database (mySQL) using PHP. The table column is a decimal number (20,2) and it is a negative amount of money. For the life of me, it will not insert as a negative, it returns a positive number. Any ideas on fixing this? I am also using WAMP server and for some reason I cannot get money_format() working. Does anyone know a quick and dirty function that will convert a stored number to look like currency? Thanks in advance for your help. Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/ Share on other sites More sharing options...
taith Posted May 2, 2007 Share Posted May 2, 2007 change it from decimal, to text/varchar... Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243490 Share on other sites More sharing options...
cheyner Posted May 2, 2007 Author Share Posted May 2, 2007 Will this allow me to perform math after? Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243500 Share on other sites More sharing options...
taith Posted May 2, 2007 Share Posted May 2, 2007 yup! you could have it as text or whatever you want, and it wont affect php atall... as long as its integers, its all good Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243522 Share on other sites More sharing options...
Ninjakreborn Posted May 2, 2007 Share Posted May 2, 2007 I know what other people think but lately I have been using varchar for almost anything related with numbers (even timestamps). It's so much easier. With any thing number related "except double for dollar amounts", I have had problems. Whenever I use varchar it always seems to work perfectly. Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243524 Share on other sites More sharing options...
taith Posted May 2, 2007 Share Posted May 2, 2007 HAPPY 3000!!!! sorry... i'm done... Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243533 Share on other sites More sharing options...
Ninjakreborn Posted May 2, 2007 Share Posted May 2, 2007 ??? Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243542 Share on other sites More sharing options...
taith Posted May 2, 2007 Share Posted May 2, 2007 (you just hit 3000 posts ) Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243550 Share on other sites More sharing options...
Ninjakreborn Posted May 2, 2007 Share Posted May 2, 2007 Oh, I had no idea what you were talking about at first, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243759 Share on other sites More sharing options...
effigy Posted May 2, 2007 Share Posted May 2, 2007 What version of MySQL? Is your decimal column marked as unsigned? I'd be careful about changing column types to get something working; they're there for a reason. Quote Link to comment https://forums.phpfreaks.com/topic/49663-solved-negative-numbers/#findComment-243763 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.