swatmo Posted June 29, 2011 Share Posted June 29, 2011 I admit I have no idea what im doing... I need to increment a field in a Mysql table based on matching another field. Here is my code. $increment_count = 'UPDATE '.$this->tablename.' SET count = count + 1 Where confirmcode = '."$referid"; if(!mysql_query($increment_count , $this->connection)) { echo 'TRIED AND FAILED AGAIN AND AGAIN'; } when I echo $increment_count i get: UPDATE emailtab SET count = count + 1 Where confirmcode = 48032da2db11eff6a851f0c3279424fd I am not sure what is wrong here. My other queries are working fine. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/ Share on other sites More sharing options...
fugix Posted June 29, 2011 Share Posted June 29, 2011 so what exactly is wrong here..your echo looks like everything is working fine Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236409 Share on other sites More sharing options...
swatmo Posted June 29, 2011 Author Share Posted June 29, 2011 Nothing changes all the count fields just sit at 0 and do not increment. Every time i run it it makes the attempt and the gives the error statement.... I have no idea why this wont work. It is probably something really simple that I am overlooking... but its been like 3 hours on this issue, and im about to rip my eyes out of my ears. Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236411 Share on other sites More sharing options...
PFMaBiSmAd Posted June 29, 2011 Share Posted June 29, 2011 The 48032da.... value is a string and must be enclosed by single-quotes in the query statement. Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236416 Share on other sites More sharing options...
fugix Posted June 29, 2011 Share Posted June 29, 2011 PFM is right, try this $increment_count = "UPDATE $this->tablename SET count = count + 1 Where confirmcode = '$referid'"; Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236419 Share on other sites More sharing options...
swatmo Posted June 29, 2011 Author Share Posted June 29, 2011 Thank you SO much... i know i know im dumb... but thanks so much for taking the time time to help me out... you saved my eyes, and my ears Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236420 Share on other sites More sharing options...
swatmo Posted June 29, 2011 Author Share Posted June 29, 2011 yes that totally worked... thanks again guys... how to i mark this as solved and give credit where its due on this site ? Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236425 Share on other sites More sharing options...
fugix Posted June 29, 2011 Share Posted June 29, 2011 there is a button in the bottom left hand of this page. Quote Link to comment https://forums.phpfreaks.com/topic/240719-having-trouble-with-a-mysql-query/#findComment-1236426 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.