The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Parse error-- help plz

Hi I am trying to compare the variable that a user would enter as the shipping state to a list of states for shipping this is my line of code where I am trying to say if the users shipping state is the same as one of the following:

Parse Error Help.......

Hi try this 1,

$city_array = explode(',','California,Arizona,New Mexico,Colorado,Utah,Nevada,Wyoming,Idaho,Oregon,Washington,Montana');
if(array_search($_POST['ShippingState'], $city_array))
{
echo 'User\'s City Found in Given List of Cities';
}
else
{
echo 'User\'s City Not Found in Given List of Cities';
}

1. When you compare you need to place them within double quotes,
2. Is Shipping state a Combo box? even then the order of selection in the combo box varies, then it may not succeed.
3. Try placing them in a array and then compare.

Parse Error

Hi,

Try this....

Code PHP:

<?php$city_list_1=explode(',','California,Arizona,New Mexico,Colorado,Utah,Nevada,Wyoming,Idaho,Oregon,Washington,Montana');$city_list_2=explode(',','North Dakota,South Dakota,Minnesota,Wisconsin,Iowa,Nebraska,Illinois,Missouri,Kansas,Oklahoma,Arkansas,Texas,Louisiana');$city_list_3=explode(',','Michigan,Indiana,Ohio,Kentucky,Tennessee,Mississippi,Alabama,Georgia,Florida,South Carolina,North Carolina,Virginia,West Virginia,Pennsylvania,Maryland,Delaware,Dist Columbia,New Jersey,New York,Connecticut,Rhode Island,Massachusetts,New Hampshire,Vermont,Maine');$city_list_4=explode(',','Hawaii,Alaska');if(in_array($_POST['ShippingState'],$city_list_1)){$ZoneShipping=@$_POST['ShippingTotal'];echo'User\'s City Found in city_list_1 Array';}elseif(in_array($_POST['ShippingState'],$city_list_2)){$ZoneShipping=@$_POST['ShippingTotal2'];echo'User\'s City Found in city_list_2 Array';}elseif(in_array($_POST['ShippingState'],$city_list_3)){$ZoneShipping=@$_POST['ShippingTotal3'];echo'User\'s City Found in city_list_3 Array';}elseif(in_array($_POST['ShippingState'],$city_list_4)){$ZoneShipping=@$_POST['ShippingTotal4'];echo'User\'s City Found in city_list_4 Array';}else{echo'User\'s City Not Found in Any List of Cities';}?>