Jump to content


This topic is now archived and is closed to further replies.


MySQL + PHP - UPDATE with do...while

Recommended Posts

Hi ... newbie (and diferent language) calling here please be pacient!

I need UPDATE a NEW table with data of OLD table (only 2 columns) in all table (1600 regs) comparing with another diferent column

The script was an parser error in first UPDATE nd stop.

<?php require_once('../Connections/connNOR2.php'); ?>

//----recordset  (OLD table)-------------

mysql_select_db($database_connNOR2, $connNOR2);
$query_rsREAJUSTAtudoVELHA = "SELECT * FROM tab082005_2";
$rsREAJUSTAtudoVELHA = mysql_query($query_rsREAJUSTAtudoVELHA, $connNOR2) or die(mysql_error());
$row_rsREAJUSTAtudoVELHA = mysql_fetch_assoc($rsREAJUSTAtudoVELHA);
$totalRows_rsREAJUSTAtudoVELHA = mysql_num_rows($rsREAJUSTAtudoVELHA);


//----recordset (NEW table)---------------

mysql_select_db($database_connNOR2, $connNOR2);
$query_rsREAJUSTAtudoNOVA = "SELECT * FROM tab01022006_2 WHERE tab_cod='$codTT'";
$rsREAJUSTAtudoNOVA = mysql_query($query_rsREAJUSTAtudoNOVA, $connNOR2) or die(mysql_error());
$row_rsREAJUSTAtudoNOVA = mysql_fetch_assoc($rsREAJUSTAtudoNOVA);
$totalRows_rsREAJUSTAtudoNOVA = mysql_num_rows($rsREAJUSTAtudoNOVA);

<?php do {

// put the "hhhh" and "eeee" where value is empty.

if ($velha_hier=='')


UPDATE tab01022006_2 SET tab_hier='hhhh',qtde_emb='eeee';  // <---PARSE ERROR ??

} else {

// put the OLD value in a NEW table

UPDATE tab01022006_2 SET tab01022006_2.tab_hier=$row_rsREAJUSTAtudoVELHA['tab_hier'], qtde_emb=$row_rsREAJUSTAtudoVELHA['qtde_emb'];


<?php } while ($row_rsREAJUSTAtudoNOVA = mysql_fetch_assoc($rsREAJUSTAtudoNOVA)); ?>



Thanks and sory about the english


Share this post

Link to post
Share on other sites
I see SQL code outside of quotes (i.e. in raw PHP), and not being ever sent to the server. That's bound to be the problem.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.