Jump to content

Update not Updating


timstring

Recommended Posts

Here is one of the simplest routines I have written--right? No, wrong. The script takes a table, folds, spindles, and mutilates it, and writes the data back to the table. Here's the code:

$Quest = "SELECT * FROM TOAWorkorders";$FindTechResult = mysql_query($Quest, $cxn)		or die ('The easter bunny is watching you' . mysql_error());while ($row = mysql_fetch_array($FindTechResult)){		       $IdNum = $row['IdNum'];      $BBT = $row['BBT'];	        $BBTArray = explode("-", $BBT);       $TechNum = $BBTArray["0"];        $Title = $BBTArray["2"];        $Name = explode(" ", $BBTArray['1']);        $FirstName = $Name["0"];        $LastName = $Name["1"];			  echo $TechNum . ' !! ' . $FirstName . ' !! ' . $LastName . ' !! ' . $Title . '<br>'; $Quest = "UPDATE TOAWorkorders SET TechNum = '$TechNum', FirstName = '$FirstName', LastName = '$LastName', Title = '$Title' WHERE IdNum = '$IdNum'";$result = mysql_query($Quest, $cxn)  or die(mysql_error());  	 }

The problem with the script is the `UPDATE` statement. The field is processed correctly, but the update only updates 2/3 of the table, leaving 33k of rows untouched. Any ideas??

Link to comment
Share on other sites

The only problem I see with the query is that you aren't escaping the values, so if any of those values contain single quotes then the query will fail. You're checking for errors though, so you would see that error message. Also, if you're referring to numeric array indexes then you can leave off the quotes for those.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...