jj20051 Posted August 20, 2008 Share Posted August 20, 2008 Ok. The Script Bellow Is Supposed To Add One To A Specific Row and Column In The Database. Unfortunately It Sets The Row To 5 No Matter What. So Either I Need A Different Code or I Need Some Help Fixing This One. $query = mysql_query("SELECT exelent FROM websites WHERE url = '$url'") or die(mysql_error()); $fun = $query + 1 ; $query = mysql_query("UPDATE websites SET exelent='$fun' WHERE url='$url'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/120591-solved-add-one/ Share on other sites More sharing options...
moselkady Posted August 20, 2008 Share Posted August 20, 2008 You should do it like this: $query = mysql_query("UPDATE websites SET exelent=exelent+1 WHERE url='$url'") or die(mysql_erro r()); Link to comment https://forums.phpfreaks.com/topic/120591-solved-add-one/#findComment-621405 Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 Mysql_Query() Will Not Return The Selected Value. It Will Return A Resource ID, From Which You Must Fetch The Number, Be It Using Mysql_Result() Or Mysql_Fetch_Array(). Alternatively, You Can Use Just One Query To Get It Done: UPDATE websites SET exelent = exelent + 1 WHERE url = '$url' please avoid capitalizing the first letter of every word. not only does it add unnecessary extra effort to your typing (i just checked), it's also just as grammatically incorrect as leaving everything in lower-case. EDIT: moselkady beat me to it, but i'm leaving this here because it's got an important sidenote. Link to comment https://forums.phpfreaks.com/topic/120591-solved-add-one/#findComment-621406 Share on other sites More sharing options...
jj20051 Posted August 20, 2008 Author Share Posted August 20, 2008 Thank You Both! Got It! Link to comment https://forums.phpfreaks.com/topic/120591-solved-add-one/#findComment-621408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.