[Last Call] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2007-10-13
Medium Priority
Last Modified: 2013-12-13
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;
Question by:samkay
  • 2
LVL 28

Accepted Solution

gamebits earned 100 total points
ID: 20070977
Do you get an error message of some sort?
LVL 20

Assisted Solution

Gawai earned 100 total points
ID: 20070993
echo $sql
it will return update query so that u will see is it correct or not

Author Comment

ID: 20071215
sorry - false alarm -  the data has been updated but the database connection info was pointing to the wrong copy of the database :)

Author Comment

ID: 20071219
thanks for looking though! I have split the points

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question