craigtolputt Posted April 21, 2011 Share Posted April 21, 2011 Hi, I am trying to build a jQuery and PHP love it button where the user clicks it and the number increments and saves to a DB. I have it all working apart from the Saving to the DB part : ) I have this currently to save but it doesnt seem to work. <?php mysql_connect("localhost", "web183-loveit", "password") or die ("Error."); mysql_select_db("web183-loveit") or die ("error"); $increase = "UPDATE results SET value=value+1 WHERE id=1;"; $active_rate = mysql_query("SELECT * FROM results WHERE id=1;"); $val = 0; if($rt = mysql_fetch_assoc($active_rate)) { $val = $rt['value']; } if($_POST['action'] == 'add') { mysql_query($increase); print $val++; } ?> Please see it here http://bit.ly/dKx15z Any ideas?? cheers Craig Quote Link to comment https://forums.phpfreaks.com/topic/234354-jquery-and-php-to-update-a-table-in-mysql/ Share on other sites More sharing options...
Stooney Posted April 21, 2011 Share Posted April 21, 2011 WHERE id=1; try WHERE id='1'; Quote Link to comment https://forums.phpfreaks.com/topic/234354-jquery-and-php-to-update-a-table-in-mysql/#findComment-1204649 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.