Mark, On Thu, Aug 28, 2003 at 09:59:18AM -0400, Mark Richards wrote: > I am still quite new to MySQL and have a basic question. I am using PHP, so > forgive me if this is more a PHP issue. > > I want to perform an update to a specific record based on a condition. In > the outer loop, I have Query1, which returns set Result1. Inside this loop, > I run an UPDATE query which returns Result2. > > // executed first query. > while ($row = mysql_fetch_assoc($result1)) > { > // get the record ID for the row we are on. > $recid = $row["id"]; > // construct a new query > $q2 ="UPDATE `table` SET `review` = 1 where id = > '".$recid."';"; > $result2 = mysql_query($q2) > } > > Is this a valid use of MySQL? I am concerned that executing the update > query might somehow effect the first one that is used in the outer loop. >
You need to make a separate connection to MySQL for the outer query to prevent the inner query from messing up the outer query's result set. See the PHP manual for obtaining the connection id's from mysql_connect and using them with other mysql functions. Regards, Fred. -- Fred van Engen XB Networks B.V. email: [EMAIL PROTECTED] Televisieweg 2 tel: +31 36 5462400 1322 AC Almere fax: +31 36 5462424 The Netherlands -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]