OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 23 Apr 2006 00:37:14 -0000 Issue 4087

php-general-digest-helplists.php.net
Date: Sat Apr 22 2006 - 19:37:14 CDT


php-general Digest 23 Apr 2006 00:37:14 -0000 Issue 4087

Topics (messages 234558 through 234576):

Re: array problem + humor (all those with joke allergies beware)
        234558 by: Jochem Maas
        234563 by: Brian V Bonini
        234565 by: Jochem Maas

Re: unique array problem
        234559 by: Rafael

Re: performance criteria on DEFINE()
        234560 by: tedd

Using Header() to pass information...
        234561 by: Todd Cary
        234564 by: Jim Lucas
        234569 by: Jochem Maas
        234570 by: Stephen Lake
        234571 by: Tim Van Wassenhove
        234572 by: M. Sokolewicz
        234573 by: Todd Cary

CMS for Auto Parts
        234562 by: CK
        234568 by: John Hicks

Re: PHP Script to open phpBB2 accounts
        234566 by: Gerr D

Re: array problem
        234567 by: Martin Alterisio

looking for shopping cart
        234574 by: Lisa A

shopping carts
        234575 by: Lisa A
        234576 by: Robert Cummings

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

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

attached mail follows:


suresh kumar wrote:
> sorry.earlier i mistyped some values.
>
> I am facing one project in my project .
>
> this is my code:
>
> a=array(0=>10,1=>10,2=>40,3=>30,4=>30,5=>10);
> b=array();
> b=array_unique($a);
> print_r($b);
> o/p getting from above code is b[0]=10,b[2]=40,b[3]=30,b[5]=10;

the OUTPUT is not what you say it is - why don't you take 5 seconds
to cut and paste the *actual* output of print_r() ???

in fact if your going to send some code - THEN SEND SOME CODE and
not some hastily typed psuedo code that doesn't run (notice the missing
dollar signs in front variaous variables??)

>
> but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;
>
> i searched php.net .i am not able to fine any solution.i am breaking
> my head for last 5 hours.

you may have searched but you didn't read very far - in five hours it's
probably possible to read every about arrays on php.net; but anyway read the following
2 pages over and over until you fully understand them - understanding php's
array datatype is practically the foundation to getting anywhere with php:

http://php.net/manual/en/language.types.array.php
http://php.net/manual/en/function.array-values.php

> i am waiting reply from any one

tell every one here that your waiting does come accross very well -
I'd stop saying it if I we're you.

get the feeling I'm picking on you? well your absolutely right,
you non-responding, dumb-question-asking, lack-of-problem-solving-initiative
oddball. Anytime you come to this list I'm going to beat programming ethic
into you until you 'get it' - either you'll end up looking like something
that resembles a real coder OR I'll end up start a inter-continental racewar -
lets see how it pans out.

attached mail follows:


Jochem's site:

<< snip >>
http://iamjochem.com/mariecke/index.php

Mariecke's daily ramblings (almost) in dutch & english... this page is
using output from a drupal system.
If nothing else they have a nice logo. ;)

Warning: main(./../blog/parse.php): failed to open stream: No such file
or directory in /home/sites/com/moulin/iamjochem/www/mariecke/blog.php
on line 24

Warning: main(): Failed opening './../blog/parse.php' for inclusion
(include_path='.:/usr/share/php4:/usr/share/php') in
/home/sites/com/moulin/iamjochem/www/mariecke/blog.php on line 24

Fatal error: Call to undefined function: parse_feed() in
/home/sites/com/moulin/iamjochem/www/mariecke/blog.php on line 25

< // snip >>

Perhaps you should take some of your own *advice*... ???

jochemiamjochem.com > /dev/null

On Sat, 2006-04-22 at 09:48, Jochem Maas wrote:
> suresh kumar wrote:
> > sorry.earlier i mistyped some values.
> >
> > I am facing one project in my project .
> >
> > this is my code:
> >
> > a=array(0=>10,1=>10,2=>40,3=>30,4=>30,5=>10);
> > b=array();
> > b=array_unique($a);
> > print_r($b);
> > o/p getting from above code is b[0]=10,b[2]=40,b[3]=30,b[5]=10;
>
> the OUTPUT is not what you say it is - why don't you take 5 seconds
> to cut and paste the *actual* output of print_r() ???
>
> in fact if your going to send some code - THEN SEND SOME CODE and
> not some hastily typed psuedo code that doesn't run (notice the missing
> dollar signs in front variaous variables??)
>
> >
> > but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;
> >
> > i searched php.net .i am not able to fine any solution.i am breaking
> > my head for last 5 hours.
>
> you may have searched but you didn't read very far - in five hours it's
> probably possible to read every about arrays on php.net; but anyway read the following
> 2 pages over and over until you fully understand them - understanding php's
> array datatype is practically the foundation to getting anywhere with php:
>
> http://php.net/manual/en/language.types.array.php
> http://php.net/manual/en/function.array-values.php
>
> > i am waiting reply from any one
>
> tell every one here that your waiting does come accross very well -
> I'd stop saying it if I we're you.
>
> get the feeling I'm picking on you? well your absolutely right,
> you non-responding, dumb-question-asking, lack-of-problem-solving-initiative
> oddball. Anytime you come to this list I'm going to beat programming ethic
> into you until you 'get it' - either you'll end up looking like something
> that resembles a real coder OR I'll end up start a inter-continental racewar -
> lets see how it pans out.

attached mail follows:


thanks Brian.

that site has not worked for, oh, 3 years - I don't see what some broken
code on some site I haven't done anything with in years has got to do
with programmer ethic (or whatever advice you were refering to).
- am I bugging you for a fix?

with regard to Suresh - do you, Brian, know how many times he has posted similar
question to this list this year? (this is the first time he has even given
an indication that he knows where the manual is let alone opened it btw) do you
know how many times he's been waiting for a reply/answer? how many times people
have given him answered? how often he has replied (like saying thank you for
instance) to anyone of the repsonses to his questions in any form whatsovever?

answers: 30+, 30+, 50+, 0

so if you want me to fix some 3y/o unused blog, that my girlfriend has
no time for, your **** out of luck.

what was the question again :-)

Brian V Bonini wrote:
> Jochem's site:
>

...

>
> Perhaps you should take some of your own *advice*... ???
>
> jochemiamjochem.com > /dev/null
>

...

>>get the feeling I'm picking on you? well your absolutely right,
>>you non-responding, dumb-question-asking, lack-of-problem-solving-initiative
>>oddball. Anytime you come to this list I'm going to beat programming ethic
>>into you until you 'get it' - either you'll end up looking like something
>>that resembles a real coder OR I'll end up start a inter-continental racewar -
>>lets see how it pans out.
>
>

attached mail follows:


        If what you want is to have a continuos secuential array (i.e. 0=>x,
1=>a, 2=>f) and there's no need for sorting the values, then you need
array_values()[1]
[1] http://php.net/array-values

suresh kumar wrote:
> I am facing one project in my project .
>
> this is my code:
>
> a=array(0=>10,1=>10,2=>20,3=>30,4=>30,5=>40);
> b=array();
> b=array_unique($a);
> print_r($b);
> o/p getting from above code is b[0]=10,b[2]=20,b[3]=30,b[5]=40;
>
> but i want the o/p be b[0]=10,b[1]=20,b[2]=30,b[3]=40;
>
> i searched php.net .i am not able to fine any solution.i am breaking
> my head for last 5 hours.i am waiting reply from any one
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx

attached mail follows:


At 3:47 PM -0500 4/21/06, Richard Lynch wrote:
>On Fri, April 21, 2006 7:52 am, Jochem Maas wrote:
>> Andy wrote:
>>> Now, one of this file can contain more than 2000 defines and we make
>>> a calculation that we will reach 8000 in 2 years.
>
>Seems to me you could extend your testing to generate 8000 constants
>in a file pretty easily, and just benchmark it and find out if it's
>acceptable.
>
>Hell, go for 16000 and 32000 tests as well, and benchmark those.
>
>The pattern should be obvious pretty quickly, and you'll know, beyond
>a shadow of a doubt, if you will be happy in 2 years. (On this
>issue.)

Yes, but in two years speeds will increase and prices will decrease
drastically. What is today's "Too Big" will become tomorrow's
"minimum requirement". For example, the $15,000 you would have spent
in 1984 for hard drive storage can be bought today for less than one
cent.

tedd
--
--------------------------------------------------------------------------------
http://sperling.com

attached mail follows:


If I use

   if ($send)
     header("location: mypage.php?message=" . $message);

the data ($message) is passed in the URL. Is there a way to pass
the data as though it was a POST method i.e. not in the URL?

Todd

attached mail follows:


Todd Cary wrote:
> If I use
>
> if ($send)
> header("location: mypage.php?message=" . $message);
>
> the data ($message) is passed in the URL. Is there a way to pass the
> data as though it was a POST method i.e. not in the URL?
>
> Todd
>
you should look into using sessions to store the data maybe?

As long as you will always be sending it to the same server.

Jim

attached mail follows:


Todd Cary wrote:
> If I use
>
> if ($send)
> header("location: mypage.php?message=" . $message);
>
> the data ($message) is passed in the URL. Is there a way to pass the
> data as though it was a POST method i.e. not in the URL?

probably, but I don't know how off the top of my head.

look into using $_SESSION instead and maybe even consider that you
could save yourself a redirect by doing something _like_:

if ($send) {
        $_POST['message'] = $message;
        include './mypage.php';
        exit;
}

now sticking stuff into $_POST or $_GET probably isn't the best tactic -
if a security guru could comment on that I'd appreciate it also!

>
> Todd
>

attached mail follows:


Where's Chris when we need him? I would be interested in also hearing his
thoughts here too.

"Jochem Maas" <jochemiamjochem.com> wrote in message
news:444A91E9.40209iamjochem.com...
> Todd Cary wrote:
>> If I use
>>
>> if ($send)
>> header("location: mypage.php?message=" . $message);
>>
>> the data ($message) is passed in the URL. Is there a way to pass the
>> data as though it was a POST method i.e. not in the URL?
>
> probably, but I don't know how off the top of my head.
>
> look into using $_SESSION instead and maybe even consider that you
> could save yourself a redirect by doing something _like_:
>
> if ($send) {
> $_POST['message'] = $message;
> include './mypage.php';
> exit;
> }
>
> now sticking stuff into $_POST or $_GET probably isn't the best tactic -
> if a security guru could comment on that I'd appreciate it also!
>
>>
>> Todd
>>

attached mail follows:


On 2006-04-22, Todd Cary <toddaristesoftware.com> wrote:
> If I use
>
> if ($send)
> header("location: mypage.php?message=" . $message);
>
> the data ($message) is passed in the URL. Is there a way to pass
> the data as though it was a POST method i.e. not in the URL?

It's impossible to change the HTTP method. So if your user-agent is
performing a GET request, a location header would result in another GET
request. Thus, unless you are using a POST method (which is odd since
you wrote that the variables are in the URL) it's not possible.

What you could do is write it into $_SESSION (and call
session_write_close before you redirect)
Or you could stuff it yourself in $_POST and include/require mypage.php

Btw, there are browsers that don't handle a relative URL for redirection
very well. I suggest that you use an absolute URL (as written in
RFC2616 section 14.30)

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>

attached mail follows:


Jochem Maas wrote:

> Todd Cary wrote:
>
>> If I use
>>
>> if ($send)
>> header("location: mypage.php?message=" . $message);
>>
>> the data ($message) is passed in the URL. Is there a way to pass the
>> data as though it was a POST method i.e. not in the URL?
>
>
> probably, but I don't know how off the top of my head.
>
> look into using $_SESSION instead and maybe even consider that you
> could save yourself a redirect by doing something _like_:
>
> if ($send) {
> $_POST['message'] = $message;
> include './mypage.php';
> exit;
> }
>
> now sticking stuff into $_POST or $_GET probably isn't the best tactic -
> if a security guru could comment on that I'd appreciate it also!
>
>>
>> Todd
>>

Actually, contrary (apparently) to what most people think on this list,
it is *not* possible (well, not in a standards-compliant way). Basically
what you do with a location header is stating that the URL provided is
in a different location (using a 3xx status code). This in turn means
(for most browsers) that they will make a new connection to the URI
provided. You can redirect both POST and GET requests (and a hundred
more), which should work fine in common browsers. A POST request getting
a `303 See Other` status should be resent (with a nice "are you sure you
wish to resubmit this data" prompt to the user; unfortunately, few
browsers do this, though most common browsers (currently) do properly
resend the data as part of a POST request to the URL provided.

Well, it's all very interesting up till now; the problem you're facing
is that you do not with to *redirect*, you wish to *force the browser to
initiate a specific type of request to a specific URI*, you use the 30x
status codes to do this (which is actually incorrect usage, but let's
just forget about / ignore that for now). That means the following:
1. a new URI is sent to the browser via the Location header
2. the browser makes a new connection to the specified URI with the
original type (ie. POST, GET, PUT, etc. (not HEAD))
3. the browser re-sends any additional data it was supposed to send
(generally only in POST and PUT requests)
Since there is no way for the server to "inject" data into that new
request (except for the URI, which is why "get redirects" work), you
can't "inject" a new POST request to a browser. Either you redirect the
existing request (via a 30x status response), or you need to have the
user re-submit a form (with potential new info provided by the script)
to the new URI.

The RFC2616 HTTP/1.1 [1] document covers this in reasonable detail.
Also, google searches for "POST redirect request" will bring up a few
articles detailing why this does not (and should not) work.

hope this help,
- tul

[1] http://www.w3.org/Protocols/rfc2616/rfc2616.html

attached mail follows:


M. Sokolewicz wrote:
> Jochem Maas wrote:
>
>> Todd Cary wrote:
>>
>>> If I use
>>>
>>> if ($send)
>>> header("location: mypage.php?message=" . $message);
>>>
>>> the data ($message) is passed in the URL. Is there a way to pass the
>>> data as though it was a POST method i.e. not in the URL?
>>
>>
>> probably, but I don't know how off the top of my head.
>>
>> look into using $_SESSION instead and maybe even consider that you
>> could save yourself a redirect by doing something _like_:
>>
>> if ($send) {
>> $_POST['message'] = $message;
>> include './mypage.php';
>> exit;
>> }
>>
>> now sticking stuff into $_POST or $_GET probably isn't the best tactic -
>> if a security guru could comment on that I'd appreciate it also!
>>
>>>
>>> Todd
>>>
>
> Actually, contrary (apparently) to what most people think on this list,
> it is *not* possible (well, not in a standards-compliant way). Basically
> what you do with a location header is stating that the URL provided is
> in a different location (using a 3xx status code). This in turn means
> (for most browsers) that they will make a new connection to the URI
> provided. You can redirect both POST and GET requests (and a hundred
> more), which should work fine in common browsers. A POST request getting
> a `303 See Other` status should be resent (with a nice "are you sure you
> wish to resubmit this data" prompt to the user; unfortunately, few
> browsers do this, though most common browsers (currently) do properly
> resend the data as part of a POST request to the URL provided.
>
> Well, it's all very interesting up till now; the problem you're facing
> is that you do not with to *redirect*, you wish to *force the browser to
> initiate a specific type of request to a specific URI*, you use the 30x
> status codes to do this (which is actually incorrect usage, but let's
> just forget about / ignore that for now). That means the following:
> 1. a new URI is sent to the browser via the Location header
> 2. the browser makes a new connection to the specified URI with the
> original type (ie. POST, GET, PUT, etc. (not HEAD))
> 3. the browser re-sends any additional data it was supposed to send
> (generally only in POST and PUT requests)
> Since there is no way for the server to "inject" data into that new
> request (except for the URI, which is why "get redirects" work), you
> can't "inject" a new POST request to a browser. Either you redirect the
> existing request (via a 30x status response), or you need to have the
> user re-submit a form (with potential new info provided by the script)
> to the new URI.
>
> The RFC2616 HTTP/1.1 [1] document covers this in reasonable detail.
> Also, google searches for "POST redirect request" will bring up a few
> articles detailing why this does not (and should not) work.
>
> hope this help,
> - tul
>
> [1] http://www.w3.org/Protocols/rfc2616/rfc2616.html

What I have done in the past is to open a new socket and pass the
  data that way. Never had a problem, but I thought there might
be an easier way. Your detailed explanation tells why there is not.

Many thanks....

attached mail follows:


Hi,

I've been commissioned to design a web application for auto parts
sales. The Flash Front end will communicate with a MySQL DB via PHP.
In addition, PHP/XML should be used with a client-side Web GUI to
upload images, part no., descriptions and inventory into the DB; a
Product Management System.

After "Googling" the returned queries have been slim, any leads on
more specific examples?

Return True,

CK
Principal/Designer/Programmer -Bushidodeep
http://bushidodeep.com/
______________________________
"Knowing is not enough, you must apply;
    willing is not enough, you must do."
                                          ---Bruce Lee

attached mail follows:


CK wrote:
> Hi,
>
> I've been commissioned to design a web application for auto parts sales.
> The Flash Front end will communicate with a MySQL DB via PHP. In
> addition, PHP/XML should be used with a client-side Web GUI to upload
> images, part no., descriptions and inventory into the DB; a Product
> Management System.
>
>
I am curious as to how you plan to using XML for the client's back end?
(I don't see any reason to use it.)

> After "Googling" the returned queries have been slim, any leads on more
> specific examples?
>
What specifically are you looking for and how are you googling for it?

--John

attached mail follows:


Richard,

On 4/20/06, Richard Lynch <ceol-i-e.com> wrote:

> Or perhaps you believe you have already completely mined out those
> resources, and PHP-General was your last resort.
>
> Which is fine, but that should have been in your original post.

Are you implying this list is intended to be a "last resort" resource?
That seems a shame, considering the talent I've seen here.

> You cannot possibly be the first (or last) developer to want this
> feature...

I would like it too. ;)

> I'm guessing that a lot of the noise here is that most posters firmly
> believe that your phpBB solution is "out there" and you just need to
> find it, somewhere in phpBB sites.

I'm guessing that most posters indeed believe that, because if you
think about it, it's logical and as such, someone would have already
created a solution. Yet believing that and sending someone off to go
look "somewhere" demonstrates that nobody has actually "seen" the
solution... Otherwise why not share it?

Gerry

attached mail follows:


You're wrong, he isn't using an associative array, since the keys used are
only integers.

array(10,10,40,30,30,10);
and
array(0=>10,1=>10,2=>40,3=>30,4=>30,5=>10);
create the same array.

The problem is that array_unique preserves keys (read the manual!!!)
If you don't want this, use array_values() to turn the array into a more
traditional array:

$a = array_values(array_unique($a));

2006/4/22, Brian V Bonini <b-boninicox.net>:
>
> On Sat, 2006-04-22 at 07:09, suresh kumar wrote:
> > sorry.earlier i mistyped some values.
> >
> > I am facing one project in my project .
> >
> > this is my code:
> >
> > a=array(0=>10,1=>10,2=>40,3=>30,4=>30,5=>10);
> > b=array();
> > b=array_unique($a);
> > print_r($b);
> > o/p getting from above code is b[0]=10,b[2]=40,b[3]=30,b[5]=10;
> >
> > but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;
>
>
> That will return:
>
> Array
> (
> [0] => 10
> [2] => 40
> [3] => 30
> )
>
> If you want:
>
> Array
> (
> [0] => 10
> [1] => 40
> [2] => 30
> )
>
>
> Don't use an associative array for $a
> $a=array(10,10,40,30,30,10);
>
> Or iterate through $a to re-sequence the index in $b.
>
> $a=array(0=>10,1=>10,2=>40,3=>30,4=>30,5=>10);
> $a=array_unique($a);
>
> foreach($a as $v) {
> $b[] = $v;
> }
>
> print_r($b);
>
> --
>
> s/:-[(/]/:-)/g
>
>
> Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
> ======================================================================
> gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
> Key Info: http://gfx-design.com/keys
> Linux Registered User #339825 at http://counter.li.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


I'm still looking for an inexpensive shopping cart to use on my client's
website. Something they can easily update their products, prices, photos,
etc once I set it up for them. It must be very simple for them to use.
Anyone write any shopping cart scripts that might work?
thanks,
Lisa A

attached mail follows:


Can anyone suggest someone to write a simple client side shopping cart I can
use? I need to install something that my client can update the merchandise
themselves. Something inxepensive please.
thanks,

attached mail follows:


On Sat, 2006-04-22 at 20:08, Lisa A wrote:
> Can anyone suggest someone to write a simple client side shopping cart I can
> use? I need to install something that my client can update the merchandise
> themselves. Something inxepensive please.

By inexpensive do you mean slave labour? $5? 100$? 1000$ 10000?

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'