Jump to content

remove leading spcae from postcode


mackin

Recommended Posts

Hi, I have a table of UK postcodes - in the format SA99 1AF etc. I have noticed that some entries have an added leading space that shouldnt be there and is affecting a radius search.

 

How do i alter this code to check for a leading space and if so remove it.?

 

mysql_select_db($database_contractors, $contractors);
$query_update_postcodes2 = "UPDATE hotels SET est_postcode =  ltrim(est_postcode) ";
$update_postcodes = mysql_query($query_update_postcodes2, $contractors) or die(mysql_error());

 

Is this anywhere near?

Link to comment
Share on other sites

cheers muddy - i shall do that shortly

Smerny - the information is added by importing spreadsheets, as i have a few people doing them the errors slipped through - but ill run the update query every week or so to change them

 

Thanks

Link to comment
Share on other sites

I got an error - have i got a comma in wrong place!!

 

Warning: mysql_affected_rows(): supplied resource is not a valid MySQL-Link resource in /homepages/27/d374255998/htdocs/ship/update_postcode.php on line 35

 

mysql_select_db($database_contractors, $contractors);
$query_update_postcodes2 = "UPDATE hotels SET est_postcode =  ltrim(est_postcode) ";
$update_postcodes = mysql_query($query_update_postcodes2, $contractors) or die(mysql_error());
$updCount = mysql_affected_rows($update_postcodes);
echo $updCount;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.