anton_1 Posted March 27, 2012 Share Posted March 27, 2012 Why won't this increment the database field by 1? $sql2="update 'users' set 'TimesLoggedOn' = 'TimesLoggedOn' + 1 where 'BarcodeID' = $barcode"; mysql_query($sql2); Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/259815-in-sequence-to-previous-question-increment-db-field-by-1/ Share on other sites More sharing options...
dragon_sa Posted March 27, 2012 Share Posted March 27, 2012 Going on your previous post $logged = $isAdmin['TimesLoggedOn']+1; $sql2=mysql_query("UPDATE users SET TimesLoggedOn = '$logged' WHERE BarcodeID = '$barcode'"); put that just above this header("location: AdminSection.php"); Quote Link to comment https://forums.phpfreaks.com/topic/259815-in-sequence-to-previous-question-increment-db-field-by-1/#findComment-1331592 Share on other sites More sharing options...
litebearer Posted March 27, 2012 Share Posted March 27, 2012 $sql2="update 'users' set 'TimesLoggedOn' = 'TimesLoggedOn' + 1 where 'BarcodeID' = $barcode"; 1. use back ticks not single quotes around field names. 2. You forgot single quotes around $barcode Quote Link to comment https://forums.phpfreaks.com/topic/259815-in-sequence-to-previous-question-increment-db-field-by-1/#findComment-1331609 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.