jscix Posted April 10, 2007 Share Posted April 10, 2007 Okay, I'm pretty sure im doing this correct, as it's updating the IP Address, but it isn't incrementing the 'total' feild, the number is staying the same. Anyone? mysql_query("UPDATE `attend` SET total=total+1, ip=$curIP WHERE attend.eid = $eventid"); Link to comment https://forums.phpfreaks.com/topic/46497-solved-sql-math/ Share on other sites More sharing options...
pocobueno1388 Posted April 10, 2007 Share Posted April 10, 2007 Have you tried printing out the error? mysql_query("UPDATE `attend` SET total=total+1, ip=$curIP WHERE attend.eid = $eventid")or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/46497-solved-sql-math/#findComment-226226 Share on other sites More sharing options...
per1os Posted April 10, 2007 Share Posted April 10, 2007 mysql_query("UPDATE `attend` SET total=(total+1), ip='$curIP' WHERE attend.eid = $eventid"); As long as attend is the table name, this should work. You have to remember that varchars need single quotes or any string, and to put math problems in parans just to be sure it produces the right result. Link to comment https://forums.phpfreaks.com/topic/46497-solved-sql-math/#findComment-226232 Share on other sites More sharing options...
jscix Posted April 10, 2007 Author Share Posted April 10, 2007 Doh, yeah Im a bit slow today I guess. The syntax was off, mysql_query("UPDATE `attend` SET `total` = `total` + 1, `ip` = '$curIP' WHERE `attend`.`eid` = '$eventid'") works fine. Thanks man. Link to comment https://forums.phpfreaks.com/topic/46497-solved-sql-math/#findComment-226233 Share on other sites More sharing options...
jscix Posted April 10, 2007 Author Share Posted April 10, 2007 "You have to remember that varchars need single quotes or any string, and to put math problems in parans" ah, okay. I didn't know this either. Thanks Link to comment https://forums.phpfreaks.com/topic/46497-solved-sql-math/#findComment-226234 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.