note 14218 added to function.mysql-query.php

From: Date: Mon, 23 Jul 2001 00:55:39 +0000
Subject: note 14218 added to function.mysql-query.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15686@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. http://www.php.net/manual/en/function.mysql-query.php

« previous php.notes (#15686) next »