note 14218 deleted from function.mysql-query by jimw

From: Date: Sat, 08 Dec 2001 22:20:50 +0000
Subject: note 14218 deleted from function.mysql-query by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22291@lists.php.net to get a copy of this message
Warning: If you use a code like below to add only a new item $dir (e.g. if not equal to the last item) to your database. Then you might get the new item first inserted to the top of your database, and the next time that you run the code, it will add the same item to the bottom of your database. Good luck! Wouter $query = "SELECT * FROM dir"; $result = mysql_query ($query); while($line = mysql_fetch_object($result)) { $olddir = $line->folders; } if ($olddir!==$dir) $insert = mysql_query("INSERT INTO dir (folders) VALUES ('$dir')"); So you need to reset the database pointer to the place where you want to write. A reading instruction before writing will not result in such.

« previous php.notes (#22291) next »