Trim is designed to remove spaces. You'll need to use the function MID to return a valid substring of the entire string.
Only registered users can see links on this board! Get registered or login to the forums!
During import, can't you also set a "fields surrounded by" parameter? I thought there was something like that so it would automatically take out quotes
The preg_replace strips off the leading and trailing double quotes, leaving you with last name comma first name. Then you use an explode to split that into two parts based on the comma.
You'll have to beef up the regular expression if there is an optional middle initial or something.
References:
Only registered users can see links on this board! Get registered or login to the forums!
Only registered users can see links on this board! Get registered or login to the forums!
Joined: Aug 30, 2005 Posts: 2064 Location: near Albany NY
Posted:
Mon Dec 17, 2007 8:59 pm
Sorry it is late and I don't have the energy to simulate this. In that last query are you sure that '$Fixed_Name_Last' is not being interpreted literally and that you don't need to escape the ' mark with a \ ? I usually prefer the two step method of putting the SQL statement into a variable (e.g., $sql = ("UPDATE ".$prefix."$table_name SET Name_Last = '$Fixed_Name_Last', Name_First = '$Fixed_Name_First' WHERE Session_ID ='$Session_ID'") and then executing that separately. That way for diagnostic purposes I can echo out the SQL I've created and see exactly how it is being interpreted. I'd also put in a check that says if (!fixname) and then echo out any mysql errors.
Practice defensive programming from the outset and check for errors as you go, echo things to make sure they are coming out the way you expect and you will find that things go a lot smoother.
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum