内爆帮助 [英] Implode Help

查看:79
本文介绍了内爆帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。


快速背景,因为我不希望任何时间都在忙碌。我是一个

PHP / SQL程序员的客户。我为程序员构建的网站是

工作得很好,但有一个例外。


我的编程经验有限,大部分是Pascal / C ++而且我现在已经很多年没有b $ b编程了,即使这样,这也是一个平庸的小编程。这个和那个。


以下是代码:


-------------------------------- ---------------------------------------


函数check_deliver_price($ product_id,$ product_quantity,$ price_level,

$ delivery_city_address,$ delivery_state_address,$ delivery_zip,

$ values_price_inc)


{


全球$ db_prefix,$ ups_dropOffChoice,$ ups_container,$ ups_billToUPS,

$ ups_15_origPostal,$ ups_14_origCountry,$ ups_13_product,$ ups_10_action;


$ result = 0;


@ $ result = mysql_query(" select * from&q uot;。$ db_prefix。" _products WHERE

id =''$ product_id''");


@ $ myrow = mysql_fetch_array($ result );


$ value = $ myrow [''price _''。$ price_level .'''_ level''] + $ values_price_inc;


if($ value< 100){$ value = 100;}

$ html = implode('''',文件

('''http://wwwapps.ups .com / ctc / htmlTool?accept_UPS_license_agreement = yes& destR

esident = 01& 49_residential = 1& 10_action =''。$ ups_10_ac tion。''& 13_product =''。$ ups_1

3_product。''& 14_origCountry =''。$ ups_14_origCountry。''& origCity =''。$ ups_origCity。

''& 15_origPostal =''。$ ups_15_origPostal。''& 22_destCoun try =''。$ ups_22_destCountry。

''& shipDate =''。date(" Ym-d")。''& document ='' 。$ ups_document。''& currency =''。$ ups_c urr

ency。''& container =''。$ ups_container。''& billToUPS =''。$ u ps_billToUPS 。''& dropOffChoi

ce =''。$ ups_dropOffChoice。''& 20_destCity =''。$ delivery_ city_address。''& 19_destPost

al = ''。$ delivery_zip。 '' &安培; 23_weight = '' $ myrow [ '' 体重 '' ]。''& 24_value =''。$ value。''& 25_l

ength =''。$ myrow [''size_x'']。''& 26_width ='' 。$ myrow [''size_y'']。''& 27_height =''。$ myrow [

''tize_z'']));


if(strstr($ html,''UPS United States''))


{


if(strstr($ html, ''提供套餐信息''))


{


$ result = 0;


}


elseif(strstr($ html,''提供货件信息'))


{

$ result = -1;


}


elseif(strstr($ html,''详细结果'') )


{


eregi(''发货总额:< / span>< img alt =""高度= QUOT 1 QUOT; src =" /img/1.gif"

width =" 12">(。+)< img alt =""高度= QUOT 1 QUOT; SRC =" /img/1.gif" width =" 6">< span

class =" bold"> USD< / span>< / div>< / td>'',$ html,$ temp );


$ result = $ temp [1];


}


else


{


order_step_1('''','''','''',''delivery_address_incorrect'');


休息;


}


}


if($ result< 0){order_step_1('''','''','''',''delivery_address_incorrect'');}


if($ myrow [''price _''。$ price_level。''_ shipping''] == 1){$ result = 0;}


$ result = $ result * $ product_quantity;


返回$ result;


}

--------------- -------------------------------------------------- ------


基本上,从我可以收集到的内容中,它在网页内查找结果

来自UPS,看看是否存在某些东西,实质上到g我已经

" check_deliver_price"结果。


使用implode在上面的代码中(就像在任何PHP代码中我会想象的那样)是我从研究中可以看出的连接函数。


然而,它似乎上面使用的内爆函数调用正在剥离客户城市地址(即Santa Fe,Los Angelos,

等)之间的空间。其中圣达菲将只是圣诞老人通过

时间连接起来。因此,仅圣诞老人通过

使用URL传递给UPS,当然UPS返回错误。


只有在城市名称中有空格的客户才有此问题。现在,我的

程序员虽然能够解决这个问题但是没有,因为她甚至不在美国,所以我无法联系她。


我要求NG提供修改上述代码的任何帮助或任何

建议我可以做什么。我不介意保留她的编码备份,

然后修改原始..此外,我不认为我可以让事情更糟糕,因为check_deliver_price"在客户注册时,函数被称为

地址验证,但是,要找出他们购买的产品的交付费用



代码的关键部分(我认为)将是:


$ html = implode('''',file

( ''http://wwwapps.ups.com/ctc/htmlTool?accept_UPS_license_agreement=yes&destR

esident = 01& 49_residential = 1& 10_action =''。$ ups_10_ac tion。''& 13_product =''。$ ups_1

3_product。''& 14_origCountry =''。$ ups_14_origCountry。''& origCity =''。$ ups_origCity。

' '& 15_origPostal =''。$ ups_15_origPostal。''& 22_destCoun try =''。$ ups_22_destCountry。

''& shipDate =''。date(" Ym-d") 。''& document =''。$ ups_document。''& currency =''。$ ups_c urr

ency。''& container =''。$ ups_container。''& ; billToUPS =''。$ u ps_billToUPS。''& dropOf fChoi

ce =''。$ ups_dropOffChoice。''& 20_destCity =''。$ delivery_ city_address。''& 19_destPost

al =''。$ delivery_zip 。''& 23_weight =''。$ myrow [''weight'']。''& 24_value =''。$ value。''& 25_l

ength =''。 $ myrow [''size_x'']。''& 26_width =''。$ myrow [''size_y'']。''& 27_height =''。$ myrow [

' 'size_z'']));

我所寻求的是对代码片段的整体解析,但我想如果

我可以从这里的任何人那里了解如何用%20来填写$ delivery_city_address变量中可能存在的任何空格

,这几乎可以解决我的问题?


任何指导都将非常感谢,虽然,修改后的代码

解决我的问题将使它变得更容易,并将是这个崇拜者最赞赏的
赞赏的帮助PHP程序员。 :)


Jeff

Hello.

Quick background as I dont wish to hog anyones time. I am a customer of a
PHP/SQL programmer. A website that I had the programmer build for me is
working great, with one exception.

I have limited programming experience, most of it Pascal/C++ and I haven''t
programmed for many years now even then it was mediocre programming of small
this and thats.

Here is the code:

-----------------------------------------------------------------------

function check_deliver_price($product_id, $product_quantity, $price_level,
$delivery_city_address, $delivery_state_address, $delivery_zip,
$values_price_inc)

{

global $db_prefix, $ups_dropOffChoice, $ups_container, $ups_billToUPS,
$ups_currency, $ups_document, $ups_22_destCountry, $ups_origCity,
$ups_15_origPostal, $ups_14_origCountry, $ups_13_product, $ups_10_action;

$result = 0;

@$result = mysql_query("select * from ".$db_prefix."_products WHERE
id=''$product_id''");

@$myrow = mysql_fetch_array($result);

$value = $myrow[''price_''.$price_level.''_level''] + $values_price_inc;

if ($value < 100) {$value = 100;}

$html = implode ('''', file
(''http://wwwapps.ups.com/ctc/htmlTool?accept_UPS_license_agreement=yes&destR
esident=01&49_residential=1&10_action=''.$ups_10_ac tion.''&13_product=''.$ups_1
3_product.''&14_origCountry=''.$ups_14_origCountry.'' &origCity=''.$ups_origCity.
''&15_origPostal=''.$ups_15_origPostal.''&22_destCoun try=''.$ups_22_destCountry.
''&shipDate=''.date("Y-m-d").''&document=''.$ups_document.''&currency=''.$ups_c urr
ency.''&container=''.$ups_container.''&billToUPS=''.$u ps_billToUPS.''&dropOffChoi
ce=''.$ups_dropOffChoice.''&20_destCity=''.$delivery_ city_address.''&19_destPost
al=''.$delivery_zip.''&23_weight=''.$myrow[''weight''].''&24_value=''.$value.''&25_l
ength=''.$myrow[''size_x''].''&26_width=''.$myrow[''size_y''].''&27_height=''.$myrow[
''size_z'']));

if (strstr($html, ''UPS United States''))

{

if (strstr($html, ''Provide Package Information''))

{

$result = 0;

}

elseif (strstr($html, ''Provide Shipment Information''))

{

$result = -1;

}

elseif (strstr($html, ''Detailed Results''))

{

eregi(''Shipment Total:</span><img alt="" height="1" src="/img/1.gif"
width="12">(.+)<img alt="" height="1" src="/img/1.gif" width="6"><span
class="bold">USD</span></div></td>'', $html, $temp);

$result = $temp[1];

}

else

{

order_step_1('''', '''', '''', ''delivery_address_incorrect'');

break;

}

}

if ($result < 0) {order_step_1('''', '''', '''', ''delivery_address_incorrect'');}

if ($myrow[''price_''.$price_level.''_shipping''] == 1) {$result = 0;}

$result = $result * $product_quantity;

return $result;

}
-----------------------------------------------------------------------

Basically, from what I can gather, its looking within the webpage result
from UPS to see if something exists, in essence to give the
"check_deliver_price" function a result.

The use of "implode" in the above code (as in any PHP coding I would
imagine) is a concatenation function from what I can tell by my research.

However, it seems that the implode function call as used above is stripping
the space in between a customers City address (ie. Santa Fe, Los Angelos,
etc.) creating a situation where "Santa Fe" would be just "Santa" by the
time it is concatenated. Therefore, only "Santa" gets passed onto UPS by
use of the URL, which of course UPS returns an error.

Only customers with a space in the city name have this issue. Now, my
programmer while capable of resolving this issue, is absent and since she is
not even in the US, I cannot contact her.

I am asking the NG for any help in modifying the above code or any
suggestions as to what I can do. I dont mind keeping backups of her coding,
then modifying the original.. besides, I dont imagine I could make matters
much worse, since the "check_deliver_price" function is called both for
address verfication upon customer sign up, but, to find out the delivery
charges of the products that they purchase.

The key portion of the code (I think) would be:

$html = implode ('''', file
(''http://wwwapps.ups.com/ctc/htmlTool?accept_UPS_license_agreement=yes&destR
esident=01&49_residential=1&10_action=''.$ups_10_ac tion.''&13_product=''.$ups_1
3_product.''&14_origCountry=''.$ups_14_origCountry.'' &origCity=''.$ups_origCity.
''&15_origPostal=''.$ups_15_origPostal.''&22_destCoun try=''.$ups_22_destCountry.
''&shipDate=''.date("Y-m-d").''&document=''.$ups_document.''&currency=''.$ups_c urr
ency.''&container=''.$ups_container.''&billToUPS=''.$u ps_billToUPS.''&dropOffChoi
ce=''.$ups_dropOffChoice.''&20_destCity=''.$delivery_ city_address.''&19_destPost
al=''.$delivery_zip.''&23_weight=''.$myrow[''weight''].''&24_value=''.$value.''&25_l
ength=''.$myrow[''size_x''].''&26_width=''.$myrow[''size_y''].''&27_height=''.$myrow[
''size_z'']));
What I seek is an overall resolution to the code sniplet, though, I think if
I can find out from anyone here on how to fill in any spaces that may exist
in the $delivery_city_address variable with a %20, that would pretty much
resolve my issue?

Any guideance would be greatly appreciated, albeit, a modified code
resolving my issue would make it much easier and would be the most
appreciated assistance for this wannabe PHP programmer. :)

Jeff

推荐答案

product_id,
product_id,


product_quantity ,
product_quantity,


price_level,
price_level,


这篇关于内爆帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆