aebstract Posted January 28, 2008 Share Posted January 28, 2008 Parse error: parse error, unexpected '}', expecting ')' in /home/virtual/site130/fst/var/www/html/Rate.php5 on line 45 Here is all the code: <?php // Copyright 2007, FedEx Corporation. All rights reserved. // Version 2.0.0 chdir('..'); require_once('library/fedex-common.php5'); $newline = "<br />"; ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient('http://www.berryequipment.net/wsdl/RateService_v2.wsdl', array('trace' => 1)); // replace with valid path to WSDL $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => 'YXSO2j7gNqcJsOSs', 'Password' => 'zcuAEs7HNaI2j2Wnlaa1Nw3G2')); // Replace 'XXX' and 'YYY' with FedEx provided credentials $request['ClientDetail'] = array('AccountNumber' => '510087380', 'MeterNumber' => '1214194');// Replace 'XXX' with your account and meter number $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v2 using PHP ***'); $request['Version'] = array('ServiceId' => 'crs', 'Major' => '2', 'Intermediate' => '0', Minor => '0'); $request['Origin'] = array('StreetLines' => array('6736 Cleveland Hwy'), // Origin details 'City' => 'Clermont', 'StateOrProvinceCode' => 'GA', 'PostalCode' => '30527', 'CountryCode' => 'US'); $request['Destination'] = array('StreetLines' => array('$street'), // Destination details 'City' => '$city', 'StateOrProvinceCode' => '$state', 'PostalCode' => '$zip', 'CountryCode' => 'US'); $request['Payment'] = array('PaymentType' => 'THIRD_PARTY'); // valid codes RECIPIENT, SENDER and THIRD_PARTY $request['DropoffType'] = 'REGULAR_PICKUP'; // valid codes BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION $request['ServiceType'] = 'FEDEX_GROUND'; // valid codes STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ... $request['PackagingType'] = 'YOUR_PACKAGING'; // valid codes FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... $request['ShipDate'] = date('Y-m-d'); $request['RateRequestTypes'] = 'ACCOUNT'; // valid codes ACCOUNT, LIST $PassRateRequestPackageSummary = true; if ($PassRateRequestPackageSummary) { // Passing multi piece shipment rate request (by setting PieceCount > 1) $request['RateRequestPackageSummary'] = array('TotalWeight' => array('Value' => 22.0, 'Units' => 'LB'), // valid codes LB and KG 'TotalInsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), 'PieceCount' => $quan, } else { // Passing single piece shipment rate request $request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage is supported $request['Packages'] = array(0 => array('Weight' => array('Value' => 22.0, 'Units' => 'LB'), // valid code LB and KG 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), } try { $response = $client ->__soapCall("getRate", array('parameters' => $request)); if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR') { printRequestResponse($client); } else { echo 'Error in processing transaction.'. $newline. $newline; foreach ($response -> Notifications as $notification) { if(is_array($response -> Notifications)) { echo $notification -> Severity; echo ': '; echo $notification -> Message . $newline; } else { echo $notification . $newline; } } } writeToLog($client); // Write to log file } catch (SoapFault $exception) { printFault($exception, $client); } ?> This part is where the line is and I'm sure the problem occurs: if ($PassRateRequestPackageSummary) { // Passing multi piece shipment rate request (by setting PieceCount > 1) $request['RateRequestPackageSummary'] = array('TotalWeight' => array('Value' => 22.0, 'Units' => 'LB'), // valid codes LB and KG 'TotalInsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), 'PieceCount' => $quan, } else { // Passing single piece shipment rate request $request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage is supported $request['Packages'] = array(0 => array('Weight' => array('Value' => 22.0, 'Units' => 'LB'), // valid code LB and KG 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), } try { This last bit of code starts on line 39 Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/ Share on other sites More sharing options...
clown[NOR] Posted January 28, 2008 Share Posted January 28, 2008 try this if ($PassRateRequestPackageSummary) { // Passing multi piece shipment rate request (by setting PieceCount > 1) $request['RateRequestPackageSummary'] = array('TotalWeight' => array('Value' => 22.0, 'Units' => 'LB'), // valid codes LB and KG 'TotalInsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), 'PieceCount' => $quan) } else { // Passing single piece shipment rate request $request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage is supported $request['Packages'] = array(0 => array('Weight' => array('Value' => 22.0, 'Units' => 'LB'), // valid code LB and KG 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), } try { Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451396 Share on other sites More sharing options...
rhodesa Posted January 28, 2008 Share Posted January 28, 2008 Yup, didn't close your array: // Passing multi piece shipment rate request (by setting PieceCount > 1) $request['RateRequestPackageSummary'] = array('TotalWeight' => array('Value' => 22.0, 'Units' => 'LB'), // valid codes LB and KG 'TotalInsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), 'PieceCount' => $quan, needs a ");" after it, before close brace Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451397 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 Okay, now when I get those closed (correct me if I did it wrong) I'm getting an error about the next line: } else { // Passing single piece shipment rate request $request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage is supported $request['Packages'] = array(0 => array('Weight' => array('Value' => 22.0, 'Units' => 'LB'), // valid code LB and KG 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'); } Parse error: parse error, unexpected '}', expecting ')' in /home/virtual/site130/fst/var/www/html/Rate.php5 on line 52 Line 52 being the one with the } If I remove the ; on 51, it gives me the error of expecting ; on 51 >.< Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451403 Share on other sites More sharing options...
Demonic Posted January 28, 2008 Share Posted January 28, 2008 change: 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'); to 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD')); Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451419 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 Now it's: Parse error: parse error, unexpected ';', expecting ')' in /home/virtual/site130/fst/var/www/html/Rate.php5 on line 51 Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451423 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 =[ Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451479 Share on other sites More sharing options...
kenrbnsn Posted January 28, 2008 Share Posted January 28, 2008 You need to make sure all your parenthesis balance: <?php { // Passing single piece shipment rate request $request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage is supported $request['Packages'] = array(array('Weight' => array('Value' => 22.0, 'Units' => 'LB'), // valid code LB and KG 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'))); }?> A print_r of the $request array shows: Array ( [PackageCount] => 1 [Packages] => Array ( [0] => Array ( [Weight] => Array ( [Value] => 22 [units] => LB ) [insuredValue] => Array ( [Amount] => [Currency] => USD ) ) ) ) Ken Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451505 Share on other sites More sharing options...
hitman6003 Posted January 28, 2008 Share Posted January 28, 2008 If you format your arrays in a more readable manner, it's much easier to see your errors: if ($PassRateRequestPackageSummary) { $request['RateRequestPackageSummary'] = array( 'TotalWeight' => array( 'Value' => 22.0, 'Units' => 'LB' ), 'TotalInsuredValue' => array( 'Amount' => $total, 'Currency' => 'USD' ), 'PieceCount' => $quan // there was an error here ); } else { $request['PackageCount'] = 1; $request['Packages'] = array( 0 => array( 'Weight' => array( 'Value' => 22.0, 'Units' => 'LB' ), 'InsuredValue' => array( 'Amount' => $total, 'Currency' => 'USD' // error here as well ) ) ); } Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451506 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 I agree with formatting it better, it was code from fedex developers ;( With that said, I'm kinda new to arrays and trying to work through their code but it's rather difficult for me. Parse error: parse error, unexpected '{' in /home/virtual/site130/fst/var/www/html/Rate.php5 on line 67 After changing what you said, hitman. I am left with this error, line 67 beginning below try { $response = $client ->__soapCall("getRate", array('parameters' => $request)); if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR') { printRequestResponse($client); } else { echo 'Error in processing transaction.'. $newline. $newline; foreach ($response -> Notifications as $notification) { if(is_array($response -> Notifications)) { echo $notification -> Severity; echo ': '; echo $notification -> Message . $newline; } else { echo $notification . $newline; } } } writeToLog($client); // Write to log file } catch (SoapFault $exception) { printFault($exception, $client); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451512 Share on other sites More sharing options...
kenrbnsn Posted January 28, 2008 Share Posted January 28, 2008 If you got this code from a 3rd Party (FedEx), don't you think you should be contacting them with the problems in their code? Ken Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451521 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 I've been trying.. many many times. Constantly throughout the day. I've gotten more help in an hour here than I have in several days of trying to contact them. I got a response back from a developer that said: "Are you rating dry ice?" I would much rather just get help here and get the code fixed. I understand there is a "3rd party" section to the forums, which hardly gets used. I looked and if I was to post this there, I would probably get a response once a day, meaning the problems would get solved in a week or two. Much better responses and response times here. If im not welcome here, okay but I hope that isn't the truth as I want really need to get this code working. Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451528 Share on other sites More sharing options...
rhodesa Posted January 28, 2008 Share Posted January 28, 2008 After changing what you said, hitman. I am left with this error, line 67 beginning below The 'try' is line 67? More then likely the problem is in the lines before that then. Post more code please. Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451538 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 The entire script is posted at the top, here it is with the most recent updates: <?php // Copyright 2007, FedEx Corporation. All rights reserved. // Version 2.0.0 chdir('..'); require_once('library/fedex-common.php5'); $newline = "<br />"; ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient('http://www.berryequipment.net/wsdl/RateService_v2.wsdl', array('trace' => 1)); // replace with valid path to WSDL $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => 'YXSO2j7gNqcJsOSs', 'Password' => 'zcuAEs7HNaI2j2Wnlaa1Nw3G2')); // Replace 'XXX' and 'YYY' with FedEx provided credentials $request['ClientDetail'] = array('AccountNumber' => '510087380', 'MeterNumber' => '1214194');// Replace 'XXX' with your account and meter number $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v2 using PHP ***'); $request['Version'] = array('ServiceId' => 'crs', 'Major' => '2', 'Intermediate' => '0', Minor => '0'); $request['Origin'] = array('StreetLines' => array('6736 Cleveland Hwy'), // Origin details 'City' => 'Clermont', 'StateOrProvinceCode' => 'GA', 'PostalCode' => '30527', 'CountryCode' => 'US'); $request['Destination'] = array('StreetLines' => array('$street'), // Destination details 'City' => '$city', 'StateOrProvinceCode' => '$state', 'PostalCode' => '$zip', 'CountryCode' => 'US'); $request['Payment'] = array('PaymentType' => 'THIRD_PARTY'); // valid codes RECIPIENT, SENDER and THIRD_PARTY $request['DropoffType'] = 'REGULAR_PICKUP'; // valid codes BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION $request['ServiceType'] = 'FEDEX_GROUND'; // valid codes STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ... $request['PackagingType'] = 'YOUR_PACKAGING'; // valid codes FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... $request['ShipDate'] = date('Y-m-d'); $request['RateRequestTypes'] = 'ACCOUNT'; // valid codes ACCOUNT, LIST $PassRateRequestPackageSummary = true; if ($PassRateRequestPackageSummary) { $request['RateRequestPackageSummary'] = array( 'TotalWeight' => array( 'Value' => 22.0, 'Units' => 'LB' ), 'TotalInsuredValue' => array( 'Amount' => $total, 'Currency' => 'USD' ), 'PieceCount' => $quan // there was an error here ); } else { $request['PackageCount'] = 1; $request['Packages'] = array( 0 => array( 'Weight' => array( 'Value' => 22.0, 'Units' => 'LB' ), 'InsuredValue' => array( 'Amount' => $total, 'Currency' => 'USD' // error here as well ) ) ); } try { $response = $client ->__soapCall("getRate", array('parameters' => $request)); if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR') { printRequestResponse($client); } else { echo 'Error in processing transaction.'. $newline. $newline; foreach ($response -> Notifications as $notification) { if(is_array($response -> Notifications)) { echo $notification -> Severity; echo ': '; echo $notification -> Message . $newline; } else { echo $notification . $newline; } } } writeToLog($client); // Write to log file } catch (SoapFault $exception) { printFault($exception, $client); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451541 Share on other sites More sharing options...
kenrbnsn Posted January 28, 2008 Share Posted January 28, 2008 I just created a file containing the above code and got no syntax errors in it. Are you still having a problem? Ken Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451545 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 Parse error: parse error, unexpected '{' in /home/virtual/site130/fst/var/www/html/Rate.php5 on line 67 Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451546 Share on other sites More sharing options...
kenrbnsn Posted January 28, 2008 Share Posted January 28, 2008 Are you sure you're using PHP5 and not PHP4. This code has no syntax errors in PHP5. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451547 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 I suppose that could be a problem, I know that all my other files on my site are just .php. Will I be able to mix that with the .php5? What happens if I remove the 5 off of it? Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451550 Share on other sites More sharing options...
duclet Posted January 28, 2008 Share Posted January 28, 2008 Alright, I think this should do the trick. And please, from now on, when writing code, keep it clean so it is easier to debug. <?php // Copyright 2007, FedEx Corporation. All rights reserved. // Version 2.0.0 chdir('..'); require_once('library/fedex-common.php5'); $newline = "<br />"; ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient('http://www.berryequipment.net/wsdl/RateService_v2.wsdl', array('trace' => 1)); // replace with valid path to WSDL $request['WebAuthenticationDetail'] = array('UserCredential' => array('Key' => 'YXSO2j7gNqcJsOSs', 'Password' => 'zcuAEs7HNaI2j2Wnlaa1Nw3G2')); // Replace 'XXX' and 'YYY' with FedEx provided credentials $request['ClientDetail'] = array('AccountNumber' => '510087380', 'MeterNumber' => '1214194'); // Replace 'XXX' with your account and meter number $request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v2 using PHP ***'); $request['Version'] = array('ServiceId' => 'crs', 'Major' => '2', 'Intermediate' => '0', Minor => '0'); $request['Origin'] = array('StreetLines' => array('6736 Cleveland Hwy'), // Origin details 'City' => 'Clermont', 'StateOrProvinceCode' => 'GA', 'PostalCode' => '30527', 'CountryCode' => 'US'); $request['Destination'] = array('StreetLines' => array('$street'), // Destination details 'City' => '$city', 'StateOrProvinceCode' => '$state', 'PostalCode' => '$zip', 'CountryCode' => 'US'); $request['Payment'] = array('PaymentType' => 'THIRD_PARTY'); // valid codes RECIPIENT, SENDER and THIRD_PARTY $request['DropoffType'] = 'REGULAR_PICKUP'; // valid codes BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION $request['ServiceType'] = 'FEDEX_GROUND'; // valid codes STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ... $request['PackagingType'] = 'YOUR_PACKAGING'; // valid codes FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... $request['ShipDate'] = date('Y-m-d'); $request['RateRequestTypes'] = 'ACCOUNT'; // valid codes ACCOUNT, LIST $PassRateRequestPackageSummary = true; if ($PassRateRequestPackageSummary) { // Passing multi piece shipment rate request (by setting PieceCount > 1) $request['RateRequestPackageSummary'] = array('TotalWeight' => array('Value' => 22.0, 'Units' => 'LB'), // valid codes LB and KG 'TotalInsuredValue' => array('Amount' => $total, 'Currency' => 'USD'), 'PieceCount' => $quan); } else { // Passing single piece shipment rate request $request['PackageCount'] = 1; // currently only one occurrence of RequestedPackage is supported $request['Packages'] = array(0 => array('Weight' => array('Value' => 22.0, 'Units' => 'LB'), // valid code LB and KG 'InsuredValue' => array('Amount' => $total, 'Currency' => 'USD'))); } try { $response = $client->__soapCall("getRate", array('parameters' => $request)); if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') { printRequestResponse($client); } else { echo 'Error in processing transaction.' . $newline . $newline; foreach ($response->Notifications as $notification) { if (is_array($response->Notifications)) { echo $notification->Severity; echo ': '; echo $notification->Message . $newline; } else { echo $notification . $newline; } } } writeToLog($client); // Write to log file } catch (SoapFault $exception) { printFault($exception, $client); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451555 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 Duclet, in response to your code: Parse error: parse error, unexpected '{' in /home/virtual/site130/fst/var/www/html/Rate.php5 on line 48 Also, I had mentioned before that it was the fedex rate script to get a price on shipping for items that we are selling. This is why I'm stuck as well, I'm not too good with arrays and it's hard to go through this code. *edit* Just talked to my host and I have php 4.2 enabled. Is there a way around the file being php5? Can I remove the 5 from the extension? Am I going to HAVE to find a way to get an upgrade for this to work? Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451561 Share on other sites More sharing options...
kenrbnsn Posted January 28, 2008 Share Posted January 28, 2008 To determine whether your server is using PHP4 or PHP5 create, upload and run the script: <?php phpinfo() ?> If the host is running PHP4, you will not be able to use this script. Go back to FedEX and get get one that runs with PHP4. PHP 4.2 is very old. Either switch hosts or ask your current host to upgrade to PHP5, since PHP4 is not being supported anymore. Ken Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451566 Share on other sites More sharing options...
duclet Posted January 28, 2008 Share Posted January 28, 2008 Now that you mention it, if I recall correctly, PHP4 does not have the try and catch syntax. It seems like you are running PHP4 so you will need PHP5 for this to work. Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451570 Share on other sites More sharing options...
aebstract Posted January 28, 2008 Author Share Posted January 28, 2008 I am going to try and get upgraded to php5 and try the script out and see what is going on. I'll get back to this topic. Thanks for the help so far! Quote Link to comment https://forums.phpfreaks.com/topic/88215-closing-out-an-array-i-think/#findComment-451572 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.