note 58712 deleted from function.mysql-query by jacques

From: Date: Wed, 07 Dec 2005 00:05:24 +0000
Subject: note 58712 deleted from function.mysql-query by jacques
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-99656@lists.php.net to get a copy of this message
Note Submitter: gunniboyh at web dot de ---- With PHP 4.3.6. (thats what i'm using) you should never use $var++ within a mysql-query. eg: <?php $link=mysql_connect("HOST","USER","PASSWORD"); mysql_select_db("mydatabase"); $var=1; mysql_query("UPDATE mytable SET mynumber=".$var++.";"); echo $var; mysql_close($link); ?> When opening this site with your browser, you get: 2 Seems to be all right. But if you select it later from your database, you will see that it's 1. However, increasing it first and then sending the mysql-query solves the problem.

« previous php.notes (#99656) next »