SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: Parse error-- help plz
-
Jun 29, 2007, 19:18 #1
- 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] == California, Arizona, New Mexico, Colorado, Utah, Nevada, Wyoming, Idaho, Oregon, Washington, Montana)
-
Jun 29, 2007, 19:43 #2
- 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';
}
-
Jun 29, 2007, 19:45 #3
- 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.
-
Jun 29, 2007, 19:48 #4
- 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] == California, Arizona, New Mexico, Colorado, Utah, Nevada, Wyoming, Idaho, Oregon, Washington, Montana)
{
$ZoneShipping = $_POST[ShippingTotal]);
}
else if($_POST[ShippingState] == North Dakota, South Dakota, Minnesota, Wisconsin, Iowa, Nebraska, Illinois, Missouri, Kansas, Oklahoma, Arkansas, Texas, Louisiana)
{
$ZoneShipping = $_POST[ShippingTotal2];
}
else if($_POST[ShippingState] == 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)
{
$ZoneShipping = $_POST[ShippingTotal3];
}
else if($_POST[ShippingState] == Hawaii, Alaska)
{
$ZoneShipping = $_POST[ShippingTotal4];
}
-
Jun 29, 2007, 22:40 #5
- 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'; } ?>
-
Jun 29, 2007, 22:50 #6
- 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]/100, 2, ".", "");
$NewTotal = number_format($_POST[ftotal] + $NewSalesTax, 2, ".", "");
$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] * $ZoneShipping, 2, ".", "");
$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 + $MyShipping, 2, ".", "");
$OrderTotal1 = number_format($OrderTotal1 + $ItemTotal, 2, ".", "");
}
$OrderTotal = number_format($OrderTotal1 + $ShippingTotal, 2, ".", "");
{
$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] * $ZoneShipping, 2, ".", "");
$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 + $MyShipping, 2, ".", "");
$OrderTotal1 = number_format($OrderTotal1 + $ItemTotal, 2, ".", "");
}
$OrderTotal = number_format($OrderTotal1 + $ShippingTotal, 2, ".", "");
$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");
?>
-
Jun 29, 2007, 23:06 #7
- 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 ?
-
Jun 29, 2007, 23:20 #8
- 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