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)) {

      $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';";
      echo "<br>ID = " . $ordID . " updated to  = " . $fullacount_trimmed;
Who is Participating?
gamebitsConnect With a Mentor Commented:
Do you get an error message of some sort?
GawaiConnect With a Mentor Commented:
echo $sql
it will return update query so that u will see is it correct or not
samkayAuthor Commented:
sorry - false alarm -  the data has been updated but the database connection info was pointing to the wrong copy of the database :)
samkayAuthor Commented:
thanks for looking though! I have split the points
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.