Jeg kan godt en sjælden gang få den til atudskrive 1, men jeg har ikke helt fundet logikken i det. Måske er det når jeg går ind på den første gang. opdaterer jeg siden går den direkte på nul igen :-/
Jeg fandt dette i php-manualen. Det løser problemerne :-)
"Note: When using UPDATE, MySQL will not update columns where the new value is the same as the old value. This creates the possiblity that mysql_affected_rows() may not actually equal the number of rows matched, only the number of rows that were literally affected by the query."
As of PHP 4.3.0 (I assume, I only tried with 4.3.2), you can make mysql_affected_rows() return the number of rows matched, even if none are updated.
You do this by setting the CLIENT_FOUND_ROWS flag in mysql_connect(). For some reason, not all the flags are defined in PHP, but you can use the decimal equivalent, which for CLIENT_FOUND_ROWS is 2.
$query= "UPDATE ..."; mysql_query($query); print mysql_affected_rows(); // more than 0 mysql_query($query); // same query twice print mysql_affected_rows(); // still more than 0
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.