Hello all and thanks for reading my question.
I have a country list in MySQL database which is part of a geo location system with zipcodes etc..
I would like to validate zipcode formats for each country and store the core of the format validation in MySql cell called valid_zip which will be in the countries data base. Like this, example using USA zipcode match
ID, Country_Name, Valid_Zip
1 , USA,
Valid_Zip Cell would have the following php code
IF ( !preg_match( '/^[0-9]{5}$/', $CheckZipCode ) ) RETURN '_ZIP_INVALID_USA'; ELSE RETURN '';
Problem is SQL doesn't like the ' single quote thing, can i just add slashes to it?
Now when I do my query for example I would do something like this
$GeoCountryArr = dbArr("SELECT * FROM `GeoCountries` WHERE ID = {$GeoIdArr['ID']} OR `Country_ID` = {$GeoIdArr['Country_ID']}");
IF ( !EMPTY( $GeoCountryArr['Valid_Zip'] ) ) {
$funcbody = $GeoCountryArr['Valid_Zip'];
$func = create_function( "", $funcbody );
$MsgErrZip = $func();
}ELSE{
do something else etc..
}
RETURN $MsgErrZip;
It seems the easiest and best way to handle this sort of thing at least as far as i can think of.
I don't want to have to create a huge list of 240 IF's or SWITCH CASE to handle this unless it is the only way.