473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implode Help

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_p rice($product_i d, $product_quanti ty, $price_level,
$delivery_city_ address, $delivery_state _address, $delivery_zip,
$values_price_i nc)

{

global $db_prefix, $ups_dropOffCho ice, $ups_container, $ups_billToUPS,
$ups_currency, $ups_document, $ups_22_destCou ntry, $ups_origCity,
$ups_15_origPos tal, $ups_14_origCou ntry, $ups_13_product , $ups_10_action;

$result = 0;

@$result = mysql_query("se lect * from ".$db_prefix."_ products WHERE
id='$product_id '");

@$myrow = mysql_fetch_arr ay($result);

$value = $myrow['price_'.$price _level.'_level'] + $values_price_i nc;

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

$html = implode ('', file
('http://wwwapps.ups.com/ctc/htmlTool?accept _UPS_license_ag reement=yes&des tR
esident=01&49_r esidential=1&10 _action='.$ups_ 10_action.'&13_ product='.$ups_ 1
3_product.'&14_ origCountry='.$ ups_14_origCoun try.'&origCity= '.$ups_origCity .
'&15_origPostal ='.$ups_15_orig Postal.'&22_des tCountry='.$ups _22_destCountry .
'&shipDate='.da te("Y-m-d").'&document= '.$ups_document .'&currency='.$ ups_curr
ency.'&containe r='.$ups_contai ner.'&billToUPS ='.$ups_billToU PS.'&dropOffCho i
ce='.$ups_dropO ffChoice.'&20_d estCity='.$deli very_city_addre ss.'&19_destPos t
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">US D</span></div></td>', $html, $temp);

$result = $temp[1];

}

else

{

order_step_1('' , '', '', 'delivery_addre ss_incorrect');

break;

}

}

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

if ($myrow['price_'.$price _level.'_shippi ng'] == 1) {$result = 0;}

$result = $result * $product_quanti ty;

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_ag reement=yes&des tR
esident=01&49_r esidential=1&10 _action='.$ups_ 10_action.'&13_ product='.$ups_ 1
3_product.'&14_ origCountry='.$ ups_14_origCoun try.'&origCity= '.$ups_origCity .
'&15_origPostal ='.$ups_15_orig Postal.'&22_des tCountry='.$ups _22_destCountry .
'&shipDate='.da te("Y-m-d").'&document= '.$ups_document .'&currency='.$ ups_curr
ency.'&containe r='.$ups_contai ner.'&billToUPS ='.$ups_billToU PS.'&dropOffCho i
ce='.$ups_dropO ffChoice.'&20_d estCity='.$deli very_city_addre ss.'&19_destPos t
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
Jul 17 '05
11 2251
"Geoff Berrow" <bl******@ckdog .co.uk> wrote in message
news:mf******** *************** *********@4ax.c om...
I noticed that Message-ID:
<AW************ *****@newssvr23 .news.prodigy.c om> from Virgil Green
contained the following:
You're welcome... and if you think you were "troublesome".. . you haven't
seen troublesome. Your question was researched, you showed your code, you
expained what you thought was wrong, and you told us what you expected. Thatwas refreshing.


I'd agree with that and though I'm pleased I was on the right lines I'm
sorry my effort did not work.

Was I wrong to suggest doing it the way I did?


Only because you were doing the entire URL rather than just the query
string. Your method caused the : and the // of the http:// string to be
replaced as well along with the /s (if there were any) separating host from
directory name information.. and the ? separating the query string from the
rest of the URL. Only the query string (and even then, only parts of it)
needed to be encoded.

However, I picked up the need for the urlencode() function from your post.
Before I saw that, I had decided to skip over the post because I didn't have
time at the moment to decipher it.

- Virgil.
Jul 17 '05 #11
I noticed that Message-ID:
<dg************ ***@newssvr23.n ews.prodigy.com > from Virgil Green
contained the following:

Was I wrong to suggest doing it the way I did?
Only because you were doing the entire URL rather than just the query
string. Your method caused the : and the // of the http:// string to be
replaced as well along with the /s (if there were any) separating host from
directory name information.. and the ? separating the query string from the
rest of the URL. Only the query string (and even then, only parts of it)
needed to be encoded.


Hmmm, I thought it would still work. Ah well, you learn something every
day.
However, I picked up the need for the urlencode() function from your post.
Before I saw that, I had decided to skip over the post because I didn't have
time at the moment to decipher it.


Teamwork <g>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3210
by: Andreas Paasch | last post by:
I'm having trouble with the implode function and need some help here. I've been reading at php.net but that didn't solve my problem. I'm having the below code: $query = "SELECT top1, top2, top3, top4, top5, top6, top7, top8, top9, pricesmall, pricelarge FROM esperia WHERE productnumber = '$bestil'";
3
5490
by: Shawn Campbell | last post by:
Here's my scenario: I'm creating a build environment with one system acting as the main build dispatcher and other systems as the build hosts. On the main build system I have Apache, MySQL and PHP installed and I'm building a website that will allow people to view/start/etc. builds. I'm trying to get PHP to implode a log file that resides on one of the host builds systems. I have the host and and the share, so what I'm passing into...
6
5620
by: Rob | last post by:
hi, using PHP 4.3.3 and Apache (ADVX) 2.0.47 and i want to get the contents of my SETI stats site : $personal = implode("", @file("http://setiathome.ssl.berkeley.edu/fcgi-bin/fcgi?email=$email&cmd=user_stats_new")); which gives me this :
5
3911
by: Geoff Berrow | last post by:
I don't particularly need to do this but I've just found out that print implode("<br>", $_SERVER); Gives the warning : Notice: Array to string conversion in c:\phpdev\www... Doesn't do it with any other array and of course foreach($_SERVER as $value){
18
5924
by: NoWhereMan | last post by:
Maybe a stupid question. ------------------------- 1 ------------------------- $str = ''; for($i=0; $i<10; $i++) $str .= $i;
1
2365
by: scatfly | last post by:
I have a set of values that were put into a form and am now using this to put into a database. this is my error: "Warning: implode() : Bad arguments. in /home/xxxxxx/public_html/login.php on line 177 Couldn't execute insert query." $today = date("Y-m-d"); $fields_str = implode(",",$fields); $values_str = implode('","',$values); <=line 177 $fields_str .=",createdate";
4
5158
by: atyndall | last post by:
OK, this is the relevant portion script: <?php $username = '__'; // MySQL Database Username. $password = '__'; // MySQL Database Password. $server = '__'; // MySQL Database server (most likely localhost).
3
3172
by: BryanA | last post by:
I'm not quite sure which function to use when I want to add a comma to the end of every line and a semi colon to the last one. Because it generates everything on the fly I can't count the rows from a db. Here's what I want to do: red, <--Comma green, <--Comma blue, <--Comma orange; <--Last one so semi colon
6
2436
by: tokcy | last post by:
Hi, I am having a problem with implode() function in PHP. whenever i am running my code it display an error like. Warning: implode() : Bad arguments. in D:\xampp\htdocs\admin\addspecs.php on line 8 and my code is $as = $_POST;
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10364
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.