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
https://forums.phpfreaks.com/topic/260339-remove-leading-spcae-from-postcode/
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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.