Jump to content

[SOLVED] Add One


jj20051

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.