I have a record set called rsOrders with a table called shipcountry_ord with the countries in it when using a check out procedure. I am trying to set a condition for free shipping, but want to only offer in the US, so I am trying to do a search for "US" in the shipcountry_ord table. When selecting "United States" from a dropdown list in the checkout procedure, "US" is placed into the shipcountry_ord table. I am trying to use the following code to search for the "US" in the shipcountry_ord table. preg_replace("/[^\d]/", "", $row_rsOrder['shipcountry_ord'])=='/US/' It isn't working, and I do not know what I am doing wrong.
your pattern matches all characters except numbers. You then replace all found characters with nothing (remove them), and attempt to match numbers against a "US". I think what you need is this: if ( $row_rsOrder['shipcountry_ord'] == 'US' ) { // it is a US order } PHP: you don't need regex, unless you store some other (additional) values in the shipcountry_ord field
and incase that there is other information within $row_rsOrder['shipcountry_ord'] as well if ( preg_match("/us/i",$row_rsOrder['shipcountry_ord']) ) { // go } PHP: