Trying to update a field in every record inside a mysql table

I have the following code thats scrolls through okay but doesn't update the table

$query="SELECT ordID, sw_accno, ordZip, ordAddress FROM orders ORDER BY ordID DESC";
$result = mysql_query($query, $dbh) or die(mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
extract($row);

      $orderID = $ordID;
      $fullacount = $ordZip . $ordAddress;
      $fullacount_nospace = str_replace (" ", "", $fullacount);
      $fullacount_trimmed = strtoupper(substr($fullacount_nospace, 0, 10));

      $sql = "UPDATE orders SET sw_accno = '$fullacount_trimmed' WHERE ordID = '$orderID';";
      mysql_query($sql);
      echo "<br>ID = " . $ordID . " updated to  = " . $fullacount_trimmed;
                  }      
samkayAsked:
Who is Participating?
 
gamebitsConnect With a Mentor Commented:
Do you get an error message of some sort?
0
 
GawaiConnect With a Mentor Commented:
try
echo $sql
it will return update query so that u will see is it correct or not
0
 
samkayAuthor Commented:
sorry - false alarm -  the data has been updated but the database connection info was pointing to the wrong copy of the database :)
0
 
samkayAuthor Commented:
thanks for looking though! I have split the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.