RE: [PHP] Missing Records

From: Date: Wed, 16 May 2001 08:08:35 +0000
Subject: RE: [PHP] Missing Records
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52993@lists.php.net to get a copy of this message
On 15-May-01 William Poarch wrote: > Hi all, > > I have a setup where I populate one table as a temporary holding place for > data. When the user's session is complete, I want to transfer all that data > to a similar, permanent table. > > The strangeness is this - most of the time the data is all transferred fine, > but sometimes only a few of the records will make it. If it always failed, > I'd just figure the code was wonky, but becuase it gets through > sporadically, I'm stumped. I'm guessing it has something to do with one > mysql_query starting up before the previous one is finished. Help, please. > > Here's the code: > > for($counter = 1; $counter <=20; $counter++) > { > if($carray[$counter] != "" && $carray[$counter] != "0") > { > $sql = "SELECT * FROM feedback_results_temp where about_user_pkey = > '$aboutradio' and by_user_pkey = '$user_pkeytemp' and competency_pkey = > '$carray[$counter]'"; > $result = mysql_query($sql); > > $num = mysql_numrows($result); > if ($num != "0") > { > $row=mysql_fetch_object($result); > $competency_pkey = $row->competency_pkey; > $rating = $row->rating; > $notes = $row->notes; > > $sql_insert = "INSERT INTO feedback_results (about_user_pkey, by_user_pkey, > competency_pkey, rating, date, notes) VALUES ('$aboutradio', > '$user_pkeytemp', '$competency_pkey', '$rating', > '$todaysdate', '$notes')"; > $result_insert = mysql_query($sql_insert); > } > } > } > > (After this, the code erases everything from feedback_results_temp) Why the SQL -> PHP -> SQL jitterbug ? $qry="INSERT INTO feedback_results (about_user_pkey,... ) SELECT about_user_pkey,by_user_pkey ... FROM feedback_results_temp WHERE about_user_pkey = '$aboutradio' AND ..."; $res=mysql_query($qry); Regards, -- Don Read dread@texas.net -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it.

« previous php.general (#52993) next »