jber Posted July 30, 2007 Share Posted July 30, 2007 Hello! I´m making a poll using PHP and MySQL. So i have a table with the next fields Idpoll which is INT and is the id of the poll Question , TEXT Answer1, TEXT Answer2, TEXT Answer3, TEXT Value1, INT Value2, INT Value3, INT Total, INT Each time an option is selected, Value has to be incremented (value=value +1) so if i press Answer1, Value1=Value+1. So the proposed query will be : (after initialising a poll of course) UPDATE polls SET Value1 = Value1+1; but when i look at Value1's value it has not been changed at all! But, more strange, if I do UPDATE polls SET Idpoll=Idpoll+1 IT DOES WORK. I don´t know what´s goin on, but something kinda strange happens (doingo the same query in the MySQL console in WAMP server does not work also, it says that the quey is OK , Rows matched : 1 Changed : 0 Warnings :0 ¿Can you please help me? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/62461-solved-problems-with-update-and-set/ Share on other sites More sharing options...
fenway Posted August 1, 2007 Share Posted August 1, 2007 SOLUTION: Sorry, i forgot to add it. The problem was if you don´t initialise some variables, the system takes them as NULL. So if you want to do value1 = value1 +1 , it is not equal as value 1 = NULL + 1 = 1. You have to initialise every numeric variable as 0 (or the value you want) Quote Link to comment https://forums.phpfreaks.com/topic/62461-solved-problems-with-update-and-set/#findComment-313033 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.