Increment

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Increment

Post by ol4pr0 »

i want to update a field by updating the number by one.

Code: Select all

//$query 1 is a insert.
$query2 = "UPDATE users SET ing=ingcount + 1 WHERE unique_id='".$_SESSION['unique_id']."' AND session='".$_COOKIE['PHPSESSID']."'";
$result = mysql_query($query2);
However its not doing.. What am i missing here.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

SET ing = ing + 1

??
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

However that doesnt seem to work.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

how is your table set-up?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

i guess u think that that unique id or session doesnt correspond with the row that should be update.
however if i would of do a select

SELECT ing from where with the same it would get that row just fine.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

hmm

the syntax looks good and if u say the table is correctly set-up, I would echo out the query to make sure the cookie n session values are being passed and read correctly in the update line

:?: :?: :?: :?:
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

yes they are.. i did an copy and paste and made a select out of it..

still a n3wbie but getting smarter lol.
Post Reply