Jump to content
timstring

Update not Updating

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??

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...