Re: mySQL Addition Problem
| From: | Szii | Date: | Wed, 16 May 2001 23:02:17 +0000 |
| Subject: | Re: mySQL Addition Problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9382@lists.php.net to get a copy of this message | ||
Remove the comma after the "SET" clause?
-Szii
----- Original Message -----
From: "Miles Thompson" <milesthompson@ns.sympatico.ca>
To: <php-db@lists.php.net>
Sent: Wednesday, May 16, 2001 3:50 PM
Subject: Re: [PHP-DB] mySQL Addition Problem
>
> Dammit, that code looks right.
>
> So ....
>
> 1. Have you tried it at the mysql console? What results?
> 2. How accurately does day match $day? Have you tried "=" instead of LIKE?
> Maybe it's doing it twice?
> 3. Is day distinct? How do you know you have only one?
>
> When you tested with 2, assuming i had a value of 1, was the result 5 or
6?
>
> Strange - Miles Thompson
>
> At 05:43 PM 5/16/01 -0400, SubvertTRL wrote:
> >I am making a simple script that counts votes per day for a site and uses
a
> >simple database, All i want to do is increment the field by one. the
first
> >time i run the script it works, after that it doubles it. so instead of
1,
> >it adds 2. i know its doubling it because i tried adding 2, 3, and 4 and
it
> >doubled all those... the field is a BIGINT UNSIGNED, i've tried it with
> >just INT, nothing seems to work, i used to have PHP get the field value,
> >increment it, then update the row in the database with the new number, it
> >doubleed it that way. now i use straight mySQL code to do it all in one
> >shot, still doubles it.. can any one help me???
> >
> >heres my code... less database info :)
> >
> >$results = mysql_query("UPDATE trlvotes SET i=i+1, WHERE day LIKE
'$day'");
> >if (mysql_affected_rows($results) == 0){
> > mysql_query("INSERT INTO trlvotes (id, day, i) VALUES (null, '$day',
1)");
> >}
> >mysql_close();
> >
> >
> >you can email me at subverttrl@yahoo.com
> >
> >thanks!
> >
> >
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-db-help@lists.php.net
> >To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net