SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:

    Here is my code I am getting a parse error.. TY in advance all.

    PHP Code:
    if($_POST[ShippingState] == CaliforniaArizona, New MexicoColoradoUtahNevadaWyomingIdahoOregonWashingtonMontana

  2. #2
    SitePoint Enthusiast jagat_21's Avatar
    Join Date
    Jun 2007
    Location
    Ahmedabad,India
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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';
    }


  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure exactly how to do this. Here is my code. I have four different shipping zones so my code looks like this .

    PHP Code:
    if($_POST[ShippingState] == CaliforniaArizona, New MexicoColoradoUtahNevadaWyomingIdahoOregonWashingtonMontana)
    {
            
    $ZoneShipping $_POST[ShippingTotal]);
    }
    else if(
    $_POST[ShippingState] == North DakotaSouth DakotaMinnesotaWisconsinIowaNebraskaIllinoisMissouriKansasOklahomaArkansasTexasLouisiana)
    {
            
    $ZoneShipping $_POST[ShippingTotal2];
    }
    else if(
    $_POST[ShippingState] == MichiganIndianaOhioKentuckyTennesseeMississippiAlabamaGeorgiaFloridaSouth CarolinaNorth CarolinaVirginiaWest VirginiaPennsylvaniaMarylandDelawareDist Columbia, New Jersey, New YorkConnecticutRhode IslandMassachusetts, New HampshireVermontMaine)
    {
            
    $ZoneShipping $_POST[ShippingTotal3];
    }
    else if(
    $_POST[ShippingState] == HawaiiAlaska)
    {
            
    $ZoneShipping $_POST[ShippingTotal4];

    If anyone can help me code this so it will work I would appreciate it. Thanks.

  5. #5
    SitePoint Enthusiast jagat_21's Avatar
    Join Date
    Jun 2007
    Location
    Ahmedabad,India
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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';
    }
    else if(in_array($_POST['ShippingState'],$city_list_2))
    {
    	$ZoneShipping = @$_POST['ShippingTotal2'];
    	echo 'User\'s City Found in city_list_2 Array';
    }
    else if(in_array($_POST['ShippingState'],$city_list_3))
    {
    	$ZoneShipping = @$_POST['ShippingTotal3'];
    	echo 'User\'s City Found in city_list_3 Array';
    }
    else if(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';
    }
    ?>


  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok here is all the code I should have put it all in here before. I just included what you put in your last thread to me.


    PHP Code:
    <?
    require_once("dbconnection.php");
    require_once(
    "header.php");

    $st explode("|"$aset[SalesTax]);

    $SalesTaxValue number_format($st[0], 2".""");

    $SalesTaxClause "<span class=SalesTax><center>$SalesTaxValue % Sales Tax will be calculated to $st[1] State residence only.</center></span>";

    $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,Ark  ansas,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');


    //show order content
    $q1 "select * from orders_content where OrderID = '$PHPSESSID' ";
    $r1 mysql_query($q1) or die(mysql_error());




    if(
    $_POST[st_state] == $_POST[BillingState])
    {
            
    $NewSalesTax number_format($_POST[ftotal] * $_POST[st_value]/1002".""");
            
    $NewTotal number_format($_POST[ftotal] + $NewSalesTax2".""");
            
    $content1 "Because of the sales tax calculation, your new order total is $ $NewTotal";
    }


    if(
    in_array($_POST['ShippingState'],$city_list_1))
    {
        
    $ZoneShipping = @$_POST['ShippingTotal'];
        echo 
    'User\'s City Found in city_list_1 Array';
    }
    else if(
    in_array($_POST['ShippingState'],$city_list_2))
    {
        
    $ZoneShipping = @$_POST['ShippingTotal2'];
        echo 
    'User\'s City Found in city_list_2 Array';
    }
    else if(
    in_array($_POST['ShippingState'],$city_list_3))
    {
        
    $ZoneShipping = @$_POST['ShippingTotal3'];
        echo 
    'User\'s City Found in city_list_3 Array';
    }
    else if(
    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';
    }



    while(
    $a1 mysql_fetch_array($r1))
    {
            if(
    $col == "1c1c1c")
            {
                    
    $col "1c1c1c";
            }
            else
            {
                    
    $col "1c1c1c";
            }

                    
    $ItemPrice number_format($a1[ItemPrice], 2".""");
                    
    $MyShipping number_format($a1[ItemQty] * $ZoneShipping2".""");
                    
    $ItemTotal number_format($a1[ItemPrice] * $a1[ItemQty], 2".""");

                    
    $content .= "<tr bgcolor=$col>\n\t<td>$a1[ItemName]</td>\n\t<td align=right>$ $ItemPrice</td>\n\t<td align=center>$a1[ItemQty]</td>\n\t<td align=right>$ $ItemTotal</td></tr>\n";

                    
    $ShippingTotal number_format($ShippingTotal $MyShipping2".""");

                    
    $OrderTotal1 number_format($OrderTotal1 $ItemTotal2".""");

            }

            
    $OrderTotal number_format($OrderTotal1 $ShippingTotal2".""");

    {
            
    $NewSalesTax "0.00";
            
    $NewTotal $_POST[ftotal];

    }
    while(
    $a1 mysql_fetch_array($r1))
    {
            if(
    $col == "1c1c1c")
            {
                    
    $col "1c1c1c";
            }
            else
            {
                    
    $col "1c1c1c";
            }

                    
    $ItemPrice number_format($a1[ItemPrice], 2".""");
                    
    $MyShipping number_format($a1[ItemQty] * $ZoneShipping2".""");
                    
    $ItemTotal number_format($a1[ItemPrice] * $a1[ItemQty], 2".""");

                    
    $content .= "<tr bgcolor=$col>\n\t<td>$a1[ItemName]</td>\n\t<td align=right>$ $ItemPrice</td>\n\t<td align=center>$a1[ItemQty]</td>\n\t<td align=right>$ $ItemTotal</td></tr>\n";

                    
    $ShippingTotal number_format($ShippingTotal $MyShipping2".""");

                    
    $OrderTotal1 number_format($OrderTotal1 $ItemTotal2".""");

            }

            
    $OrderTotal number_format($OrderTotal1 $ShippingTotal2".""");

    $today time();

    $q1 "insert into orders set 
                                            SubTotal = '
    $OrderTotal1',
                                            ShippingPrice = '
    $_POST[ShippingPrice]',
                                            SalesTax = '
    $NewSalesTax',                                
                                            OrderTotal = '
    $NewTotal',
                                            ShipToFirstName = '
    $_POST[FirstName]',                                        
                                            ShipToLastName = '
    $_POST[LastName]',
                                            ShipToAddress1 = '
    $_POST[ShippingAddress1]',
                                            ShipToAddress2 = '
    $_POST[ShippingAddress2]',
                                            ShipToCity = '
    $_POST[ShippingCity]',
                                            ShipToCountry = '
    $_POST[ShippingCountry]',
                                            ShipToState = '
    $_POST[ShippingState]',
                                            ShipToPhone = '
    $_POST[ShippingPhone]',
                                            ShipToZIP = '
    $_POST[ShippingZip]',
                                            BillToFirstName = '
    $_POST[ch1]',
                                            BillToLastName = '
    $_POST[ch2]',
                                            BillToAddress1 = '
    $_POST[BillingAddress1]',
                                            BillToAddress2 = '
    $_POST[BillingAddress2]',
                                            BillToCity = '
    $_POST[BillingCity]',
                                            BillToState = '
    $_POST[BillingState]',
                                            BillToCountry = '
    $_POST[BillingCountry]',
                                            BillToZIP = '
    $_POST[BillingZip]',
                                            BillToPhone = '
    $_POST[BillingPhone]',
                                            ClientEmail = '
    $_POST[YourEmail]',
                                            OrderDate = '
    $today' ";
    mysql_query($q1) or die(mysql_error());

    //get the OrderID
    $q1 "select last_insert_id()";
    $r1 mysql_query($q1) or die(mysql_error());
    $a1 mysql_fetch_array($r1);

    mysql_query("update orders_content set OrderID = '$a1[0]' where OrderID = '$PHPSESSID' ") or die(mysql_error());

    require_once(
    "templates/PaymentTemplate.php");

    require_once(
    "footer.php");

    ?>
    I did not get anything for shipping and it didnt echo anything out .

  7. #7
    SitePoint Enthusiast jagat_21's Avatar
    Join Date
    Jun 2007
    Location
    Ahmedabad,India
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If possible then can u show me the code of form from where you are taking inputs ?

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok I didnt figure it out I am still up working on it. I have a new error so I am going to put up a new post
    Last edited by JustMe917; Jun 30, 2007 at 02:38.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •