php-general Digest 24 Jul 2009 12:41:20 -0000 Issue 6247

Topics (messages 295775 through 295805):

Re: Undefined Index ...confusion] (RESOLVED)
        295775 by: Miller, Terion

Re: Renaming all variables in a repository
        295776 by: Stuart

Question on code profiling
        295777 by: Andrew Ballard
        295778 by: Robert Cummings
        295780 by: Ben Dunlap
        295781 by: Andrew Ballard
        295782 by: Andrew Ballard
        295783 by: Jonathan Tapicer
        295784 by: Ben Dunlap
        295792 by: Andrew Ballard
        295804 by: Lupus Michaelis

Re: Compare PHP settings of two different servers
        295779 by: Ben Dunlap

Re: Writing to CD/DVD?
        295785 by: Clancy
        295786 by: Diogo Neves
        295787 by: Nitsan Bin-Nun

Re: Doubt regarding session_destroy() in PHP 5
        295788 by: Lupus Michaelis

Re: Mediawiki's url confusion
        295789 by: Dengxule
        295791 by: sean greenslade
        295800 by: Paul M Foster
        295803 by: Dengxule

Re: Structure of PHP files
        295790 by: Lupus Michaelis

A form and an array
        295793 by: Jason Carson
        295794 by: David Robley
        295795 by: Jason Carson
        295796 by: David Robley
        295797 by: Jason Carson
        295798 by: Warren Vail
        295799 by: Jason Carson
        295801 by: Dengxule
        295802 by: Jason Carson

This is the kind of [expletives deleted] answer that is certain to prevent bugs 
being reported.
        295805 by: Per Jessen

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Thanks


On 7/23/09 9:52 AM, "Kyle Smith" <[email protected]> wrote:

Sorry, list, I did a reply instead of a reply-to-all.  This is what I
sent to "Miller, Terion"

Miller, Terion wrote:
> Thanks for the link Kyle!! Great thing there...(seriously I didn't know...I 
> learn something everyday)
>
> Anyways the link to my script is:  http://pastebin.ca/1504393
>
Your email client is annoying, it doesn't quote.  Haha.

Anyway, so, you're loading up that array with arrays of arrays, here:

   1.
      $position = 1;
   2.

   3.
      while ($row = mysql_fetch_array
      
<http://www.php.net/mysql_fetch_array><http://www.php.net/mysql_fetch_array>($result))
   4.
        {
   5.
            $_SESSION['fullRestaurantList'][$position] = $row;
   6.
            $position++;
   7.
        }
   8.

   9.
        $_SESSION['totalNumberOfRestaurants'] = $position;

So, if you get 7 rows.  Your array will have:

Array => (Row 1 Data)
Array => (Row 2 Data)

.. etc

You do not have ['fullRestaurantList']['ID'].  In the page you're
referencing you use something like
$_SESSION['fullRestaurantList'][$i]['SomeValue'].  I assume $i is the
"Position" in the array, so you likely want to use
$_SESSION['fullRestaurantList'][$i]['ID'] to get the ID field from that row.

If you need a quick dump to better understand what data you have in your
session, try making a page called session_dump.php in the same directory
with this source:

<pre><? print_r($_SESSION) ?></pre>

That will give you a good idea of what your session array looks like,
and you should see clearly that ['fullRestaurantList']['ID'] does not exist.

Hope this helps!

- Kyle



--- End Message ---
--- Begin Message ---
2009/7/23 Eddie Drapkin <[email protected]>:
> Hey all,
> we've got a repository here at work, with something like 55,000 files
> in it. For the last few years, we've been naming $variables_like_this
> and functions_the_same($way_too).  And now we've decided to switch to
> camelCasing everything and I've been tasked with somehow determining
> if it's possible to automate this process.  Usually, I'd just use the
> IDE refactoring functionality, but doing it on a
> per-method/per-function and a per-variable basis would take weeks, if
> not longer, not to mention driving everyone insane.
>
> I've tried with regular expressions, but I can't make them smart
> enough to distinguish between builtins and userland code.  I've looked
> at the tokenizer and it seems to be the right way forward, but that's
> also a huge project to get that to work.
>
> I was wondering if anyone had had any experience doing this and could
> either point me in the right direction or just down and out tell me
> how to do it.

I'd question the wisdom of doing such a thing at all. When it comes to
coding standards the important thing is not what they are, just that
they exist and are observed by everybody.

This sounds like a colossal waste of time, whether you can find an
automated method or not, for no apparent gain. Seriously, what's the
benefit of using camel over underscores? Sounds like a decision made
by a manager who feels the need to create work when none is actually
required.

-Stuart

-- 
http://stut.net/

--- End Message ---
--- Begin Message ---
I'm trying to profile a site on our development server to see why it
takes around 4 seconds to generate a pretty basic page. I installed
xdebug to use for the profiling, and now I'm really confused. Even
though it takes around 4 seconds to build the entire page, the profile
says that the total processing time is around 416ms. I thought it
might be calls to require_once/include/include_once. While they are
significant (around 46%), it says they only account for 193ms. What
could account for that much difference between what xdebug calculates
versus the total elapsed time?

Andrew

--- End Message ---
--- Begin Message ---
Andrew Ballard wrote:
I'm trying to profile a site on our development server to see why it
takes around 4 seconds to generate a pretty basic page. I installed
xdebug to use for the profiling, and now I'm really confused. Even
though it takes around 4 seconds to build the entire page, the profile
says that the total processing time is around 416ms. I thought it
might be calls to require_once/include/include_once. While they are
significant (around 46%), it says they only account for 193ms. What
could account for that much difference between what xdebug calculates
versus the total elapsed time?

Andrew

Any embedded remote elements in it like that punk Google analytics which I often see lagging my page requests on various sites?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
> significant (around 46%), it says they only account for 193ms. What
> could account for that much difference between what xdebug calculates
> versus the total elapsed time?

Are you counting "total elapsed time" from the perspective of the web browser?
If so, YSlow might be helpful:

http://developer.yahoo.com/yslow/

Ben
--
Twitter: @bdunlap

--- End Message ---
--- Begin Message ---
On Thu, Jul 23, 2009 at 4:51 PM, Robert Cummings<[email protected]> wrote:
> Andrew Ballard wrote:
>>
>> I'm trying to profile a site on our development server to see why it
>> takes around 4 seconds to generate a pretty basic page. I installed
>> xdebug to use for the profiling, and now I'm really confused. Even
>> though it takes around 4 seconds to build the entire page, the profile
>> says that the total processing time is around 416ms. I thought it
>> might be calls to require_once/include/include_once. While they are
>> significant (around 46%), it says they only account for 193ms. What
>> could account for that much difference between what xdebug calculates
>> versus the total elapsed time?
>>
>> Andrew
>
> Any embedded remote elements in it like that punk Google analytics which I
> often see lagging my page requests on various sites?
>
> Cheers,
> Rob.

Nope. Basically it connects to a database to load an ACL (which at
this point is empty, so even that isn't doing much work) and spits out
"Hello World". I timed the page top-to-bottom using microtime to make
sure it wasn't network latency, and the elapsed time it calculated is
very close to the time I see displayed by the YSlow browser extension
(around 4 sec.). The server uses eAccelerator with both caching and
optimization enabled.

This is another one of those ZendFramework sites I'm setting up. (Last
time, I brought the execution time down considerably by moving the
framework from a network drive to a local drive, but that's already in
place this time.)

A simple <?php phpinfo() ?> page executes very quickly (about
0.01seconds timed w/microtime, under a half second recorded in YSlow),
so I can't see that this could be held up any by IIS (yes, it's a
Windows server).

Even if the page is getting bogged down in calls to
include(_once)/require(_once), shouldn't that time still be reflected
in the profile calculation?

I thought xdebug was supposed to be a pretty good profiler. If it
calculating the time correctly, where are the other ~3.6 seconds
going?

Andrew

--- End Message ---
--- Begin Message ---
On Thu, Jul 23, 2009 at 5:10 PM, Ben Dunlap<[email protected]> wrote:
>> significant (around 46%), it says they only account for 193ms. What
>> could account for that much difference between what xdebug calculates
>> versus the total elapsed time?
>
> Are you counting "total elapsed time" from the perspective of the web browser?
> If so, YSlow might be helpful:
>
> http://developer.yahoo.com/yslow/
>
> Ben
> --
> Twitter: @bdunlap
>

I'm using YSlow too.

Here's the last run I did:
YSlow: 4.494 seconds
Elapsed (microtime(true) - $start): 3.990795135498 seconds
xdebug(WinCacheGrind): 402ms (0.402 seconds)

Andrew

--- End Message ---
--- Begin Message ---
Just an idea: try using the (microtime(true) - $start) approach in
portions of code to try isolate the portion that is taking more time.
Sometimes that helps me to find "the" function that is slowing
everything down.

Jonathan

On Thu, Jul 23, 2009 at 6:18 PM, Andrew Ballard<[email protected]> wrote:
> On Thu, Jul 23, 2009 at 5:10 PM, Ben Dunlap<[email protected]> wrote:
>>> significant (around 46%), it says they only account for 193ms. What
>>> could account for that much difference between what xdebug calculates
>>> versus the total elapsed time?
>>
>> Are you counting "total elapsed time" from the perspective of the web 
>> browser?
>> If so, YSlow might be helpful:
>>
>> http://developer.yahoo.com/yslow/
>>
>> Ben
>> --
>> Twitter: @bdunlap
>>
>
> I'm using YSlow too.
>
> Here's the last run I did:
> YSlow: 4.494 seconds
> Elapsed (microtime(true) - $start): 3.990795135498 seconds
> xdebug(WinCacheGrind): 402ms (0.402 seconds)
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
> Nope. Basically it connects to a database to load an ACL (which at
> [...]
> I thought xdebug was supposed to be a pretty good profiler. If it
> calculating the time correctly, where are the other ~3.6 seconds
> going?

One night I saw a script wait indefinitely for a response from a tanked
database, and PHP's max_execution_time trigger never fired to end the script,
even though it was set to a pretty low value. Some poking around led me to
http://us.php.net/manual/en/function.set-time-limit.php where I found this odd
note:

"Any time spent on activity that happens outside the execution of the script
such as system calls using system(), stream operations, database queries, etc.
is not included when determining the maximum time that the script has been
running. This is not true on Windows where the measured time is real."

The last sentence was particularly confusing because I was running on Windows.

At any rate, if xdebug is using the same mechanism used by set_time_limit() and
max_execution_time, perhaps that could explain your discrepancy?

I second Jonathan's suggestion; I would try calling microtime() before and
after your database query, and before and after anything else that isn't
strictly "execution of the script".

Ben
--
Twitter: @bdunlap

--- End Message ---
--- Begin Message ---
On Thu, Jul 23, 2009 at 5:32 PM, Ben Dunlap<[email protected]> wrote:
> I second Jonathan's suggestion; I would try calling microtime() before and
> after your database query, and before and after anything else that isn't
> strictly "execution of the script".
>
> Ben

I tried this where I could. (The ZF library itself is on a local
machine drive where I don't have access to edit the files, so I can
only edit files within the project itself. That means I can't inspect
too deeply.) I'm starting to think perhaps there is a bug in either
xdebug or WinCacheGrind. From what I can tell, the numbers I see in
WinCacheGrind look like they are off by about a factor of 10 pretty
uniformly.

Andrew

--- End Message ---
--- Begin Message ---
Andrew Ballard a écrit :
I'm trying to profile a site on our development server to see why it
takes around 4 seconds to generate a pretty basic page.
Last time I seen this is when I did validate DOM Document without DTD on local disk :D

  Can you put somewhere the essential code that take time ?

--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

Seeking for a position <http://lupusmic.org/pro/>

--- End Message ---
--- Begin Message ---
> Thank you for replying.
>> Just diff the HTML. 
> Unfortunately it is not that easy. Even if the same PHP modules are 
> present, if they are written into the page in a different place, they 
> show up as differences. The same goes for all the HTML tags and 
> everything else, so what I end up with is a ton of text, no more 
> streamlined or easy to analyze than the original output from
> phpinfo().

Do you have shell access on these servers, and are they running Linux or the
like? If so, this seems like what you'd want:

  php -i | sort -u

Ben
--
Twitter: @bdunlap

--- End Message ---
--- Begin Message ---
Does anyone know of an extension/utility that will enable PHP to write backup 
files to a
CD/DVD?

Ideally I would like the CD to appear as 'just another drive'.


--- End Message ---
--- Begin Message ---
On Fri, Jul 24, 2009 at 12:20 AM, Clancy <[email protected]> wrote:

> Does anyone know of an extension/utility that will enable PHP to write
> backup files to a
> CD/DVD?
>
> Ideally I would like the CD to appear as 'just another drive'.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
If,
1. You are using linux
2. You can make system calls
It will help:
http://www.andrews-corner.org/burning.html

-- 
Thanks,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt

--- End Message ---
--- Begin Message ---
That's what I was just about writting.

If you use linux --> you can shot calls to the system and watch it's
response!

Then all you have to do is to install a cd burning software which have an
ability to control it through the terminal!

Good luck mate!

On Fri, Jul 24, 2009 at 1:47 AM, Diogo Neves <[email protected]> wrote:

> On Fri, Jul 24, 2009 at 12:20 AM, Clancy <[email protected]> wrote:
>
> > Does anyone know of an extension/utility that will enable PHP to write
> > backup files to a
> > CD/DVD?
> >
> > Ideally I would like the CD to appear as 'just another drive'.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> If,
> 1. You are using linux
> 2. You can make system calls
> It will help:
> http://www.andrews-corner.org/burning.html
>
> --
> Thanks,
>
> Diogo Neves
> Web Developer @ SAPO.pt by PrimeIT.pt
>

--- End Message ---
--- Begin Message ---
Ashley Sheridan a écrit :
But *how* does it offer more security? You've not actually mentioned
that!

Because you need database slice access to manage the session, and not only file access in /tmp/ (where sessions belongs, by default). So now the problem is : and what about the configuration file that lies in my filesystem ? :D

--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

Seeking for a position <http://lupusmic.org/pro/>

--- End Message ---
--- Begin Message ---
Thanks a lot. As far as i know, both methods dealing with urls are
WEB-SERVER-TECH. While I was installing mediawiki, i did nothing with the
file "httpd.conf", no changes made on <mod_rewrite>.

The mediawiki install script cannot do nothing to httpd.conf i think.

So i'm confused about how the url-rewriting mechanism is activited.

Best Wishes~

Deng
09/07/24


2009/7/23 Ford, Mike <[email protected]>

> > -----Original Message-----
> > From: Paul M Foster [mailto:[email protected]]
> > Sent: 23 July 2009 06:13
> >
> > On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?????? wrote:
> >
> > > But I cannot help myself with the url pattern :
> > > /somepath_to_mediawiki/index.php/pagetitle.
> > >
> > > How can this kind of url be parsed to the file "index.php" and the
> > > "pagetitle" be parsed as params?
> > >
> > > Why the web server not go straight into path "index.php/" and look
> > for the
> > > file named "pagetitle" ?
> > >
> >
> > This type of thing is common for sites using the "MVC" or
> > "Model-View-Controller" paradigm. The index.php file is what's
> > called a
> > "front controller". A front controller is usually the entrance to
> > all
> > the other pages of a site. URLs like this often take advantage of an
> > Apache feature called "mod_rewrite", which tells Apache how to
> > handle
> > URLs which look like this.
>
> Or by the "pathinfo" mechanism, which I believe is also supported by other
> Web servers, and can work just as well, if it satisfies your requirements,
> without all the complications of mod_rewrite.
>
>
> Cheers!
>
> Mike
>  --
> Mike Ford,
> Electronic Information Developer,Libraries and Learning Innovation,
> Leeds Metropolitan University, C507, Civic Quarter Campus,
> Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
> Email: [email protected]
> Tel: +44 113 812 4730
>
>
>
>
>
>
> To view the terms under which this email is distributed, please go to
> http://disclaimer.leedsmet.ac.uk/email.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Thu, Jul 23, 2009 at 10:28 PM, Dengxule <[email protected]> wrote:

> Thanks a lot. As far as i know, both methods dealing with urls are
> WEB-SERVER-TECH. While I was installing mediawiki, i did nothing with the
> file "httpd.conf", no changes made on <mod_rewrite>.
>
> The mediawiki install script cannot do nothing to httpd.conf i think.
>
> So i'm confused about how the url-rewriting mechanism is activited.
>
> Best Wishes~
>
> Deng
> 09/07/24
>
>
> 2009/7/23 Ford, Mike <[email protected]>
>
> > > -----Original Message-----
> > > From: Paul M Foster [mailto:[email protected]]
> > > Sent: 23 July 2009 06:13
> > >
> > > On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?????? wrote:
> > >
> > > > But I cannot help myself with the url pattern :
> > > > /somepath_to_mediawiki/index.php/pagetitle.
> > > >
> > > > How can this kind of url be parsed to the file "index.php" and the
> > > > "pagetitle" be parsed as params?
> > > >
> > > > Why the web server not go straight into path "index.php/" and look
> > > for the
> > > > file named "pagetitle" ?
> > > >
> > >
> > > This type of thing is common for sites using the "MVC" or
> > > "Model-View-Controller" paradigm. The index.php file is what's
> > > called a
> > > "front controller". A front controller is usually the entrance to
> > > all
> > > the other pages of a site. URLs like this often take advantage of an
> > > Apache feature called "mod_rewrite", which tells Apache how to
> > > handle
> > > URLs which look like this.
> >
> > Or by the "pathinfo" mechanism, which I believe is also supported by
> other
> > Web servers, and can work just as well, if it satisfies your
> requirements,
> > without all the complications of mod_rewrite.
> >
> >
> > Cheers!
> >
> > Mike
> >  --
> > Mike Ford,
> > Electronic Information Developer,Libraries and Learning Innovation,
> > Leeds Metropolitan University, C507, Civic Quarter Campus,
> > Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
> > Email: [email protected]
> > Tel: +44 113 812 4730
> >
> >
> >
> >
> >
> >
> > To view the terms under which this email is distributed, please go to
> > http://disclaimer.leedsmet.ac.uk/email.htm
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

It could use a .htaccess file. Look in the directory of the index.php file
for a file named .htaccess

-- 
--Zootboy

--- End Message ---
--- Begin Message ---
On Fri, Jul 24, 2009 at 10:28:52AM +0800, Dengxule wrote:

> Thanks a lot. As far as i know, both methods dealing with urls are
> WEB-SERVER-TECH. While I was installing mediawiki, i did nothing with the
> file "httpd.conf", no changes made on <mod_rewrite>.
> 
> The mediawiki install script cannot do nothing to httpd.conf i think.
> 
> So i'm confused about how the url-rewriting mechanism is activited.

This can also be accomplished by Apache's "lookback" feature. If it's
turned on on the server, Apache will look back through the URL until it
finds something which is a file, and then consider the remainder of the
URL parameters, which it provides to the file. Thus,

http://example.com/index.php/pepperoni/pizza

will end up at http://example.com/index.php with pepperoni/pizza as
parameter, assuming that pepperoni and pizza are not files/directories
and index.php is not a directory.

The lookback feature can be turned on in the Apache configuration file,
which, on a public server, you have no access to.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
I think PATHINFO is probably what i'm looking for.

Paul mentioned the "lookback" feature, i think that is or about the same
thing.

MediaWiki-1.15.1 use the pattern of url for common pages like this :
some_path_to_mediawiki/index.php/something , and the 'something' supports
even non-english characters. Maybe this kind of usage to transfer params can
improve the SEO ?

I was trapped in the question "how can the MediaWiki scripts affect the
apache's behaviour", then finally found out it just takes advantage of the
existing "FEATURE" when i tried this kind of url to my script which var_dump
the $_SERVER and saw the "pathinfo" ...

Thank you all, best wishes ~

Deng

2009/7/23 Ford, Mike <[email protected]>

> > -----Original Message-----
> > From: Paul M Foster [mailto:[email protected]]
> > Sent: 23 July 2009 06:13
> >
> > On Thu, Jul 23, 2009 at 11:57:51AM +0800, ?????? wrote:
> >
> > > But I cannot help myself with the url pattern :
> > > /somepath_to_mediawiki/index.php/pagetitle.
> > >
> > > How can this kind of url be parsed to the file "index.php" and the
> > > "pagetitle" be parsed as params?
> > >
> > > Why the web server not go straight into path "index.php/" and look
> > for the
> > > file named "pagetitle" ?
> > >
> >
> > This type of thing is common for sites using the "MVC" or
> > "Model-View-Controller" paradigm. The index.php file is what's
> > called a
> > "front controller". A front controller is usually the entrance to
> > all
> > the other pages of a site. URLs like this often take advantage of an
> > Apache feature called "mod_rewrite", which tells Apache how to
> > handle
> > URLs which look like this.
>
> Or by the "pathinfo" mechanism, which I believe is also supported by other
> Web servers, and can work just as well, if it satisfies your requirements,
> without all the complications of mod_rewrite.
>
>
> Cheers!
>
> Mike
>  --
> Mike Ford,
> Electronic Information Developer,Libraries and Learning Innovation,
> Leeds Metropolitan University, C507, Civic Quarter Campus,
> Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
> Email: [email protected]
> Tel: +44 113 812 4730
>
>
>
>
>
>
> To view the terms under which this email is distributed, please go to
> http://disclaimer.leedsmet.ac.uk/email.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Sándor Tamás (HostWare Kft . ) a écrit :
It isn't really a programming question, but rather a structural.
  It is part of our burden ;)

Which is the better approach:
They are no better approch, only bad ones. I'm using to organize my code in module. Each module require the needed modules. This design permit me to ease case testing, and ease maintenance because you know quite fast what module can be impact by the alteration of another.

I never have to speak about scallability of this method, because I never work on a very big system. But that's optimization, I think it'll need some sed (sed -i 's/\<require_once\>/require_ondemand/' project/) and a strong mecanism to provide including on demand.

--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

Seeking for a position <http://lupusmic.org/pro/>

--- End Message ---
--- Begin Message ---
Hello everyone,

Lets say I have a file called form.php with the following form on it that
redirects to index.php when submitted. I would like to take the values of
the text fields in the form and put them into an array, then be able to
display the values in that array on index.php Does anyone know how I would
do that?

Here is my form...

<form action="index.php" method="post">
<table>
  <tr>
    <td>Option1</td>
    <td><input type="text" name="option[]" /></td>
  </tr>
  <tr>
    <td>Option2</td>
    <td><input type="text" name="option[]" /></td>
  </tr>
  <tr>
    <td></td>
    <td><input value=submit" name="submit" type="submit" /></td>
  </tr>
</table>
</table></form>



--- End Message ---
--- Begin Message ---
Jason Carson wrote:

> Hello everyone,
> 
> Lets say I have a file called form.php with the following form on it that
> redirects to index.php when submitted. I would like to take the values of
> the text fields in the form and put them into an array, then be able to
> display the values in that array on index.php Does anyone know how I would
> do that?
> 
> Here is my form...
> 
> <form action="index.php" method="post">
> <table>
>   <tr>
>     <td>Option1</td>
>     <td><input type="text" name="option[]" /></td>
>   </tr>
>   <tr>
>     <td>Option2</td>
>     <td><input type="text" name="option[]" /></td>
>   </tr>
>   <tr>
>     <td></td>
>     <td><input value=submit" name="submit" type="submit" /></td>
>   </tr>
> </table>
> </table></form>

You'll find they are already in an array which you can access as
$_POST['option'] - from there foreach() should be the next step.


Cheers
-- 
David Robley

Polls show that 9 out of 6 schizophrenics agree.
Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. 


--- End Message ---
--- Begin Message ---
> Jason Carson wrote:
>
>> Hello everyone,
>>
>> Lets say I have a file called form.php with the following form on it
>> that
>> redirects to index.php when submitted. I would like to take the values
>> of
>> the text fields in the form and put them into an array, then be able to
>> display the values in that array on index.php Does anyone know how I
>> would
>> do that?
>>
>> Here is my form...
>>
>> <form action="index.php" method="post">
>> <table>
>>   <tr>
>>     <td>Option1</td>
>>     <td><input type="text" name="option[]" /></td>
>>   </tr>
>>   <tr>
>>     <td>Option2</td>
>>     <td><input type="text" name="option[]" /></td>
>>   </tr>
>>   <tr>
>>     <td></td>
>>     <td><input value=submit" name="submit" type="submit" /></td>
>>   </tr>
>> </table>
>> </table></form>
>
> You'll find they are already in an array which you can access as
> $_POST['option'] - from there foreach() should be the next step.
>
>
> Cheers
> --
> David Robley
>
> Polls show that 9 out of 6 schizophrenics agree.
> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I am new to programming. How would I use foreach()to display the entries
in the array?



--- End Message ---
--- Begin Message ---
Jason Carson wrote:

>> Jason Carson wrote:
>>
>>> Hello everyone,
>>>
>>> Lets say I have a file called form.php with the following form on it
>>> that
>>> redirects to index.php when submitted. I would like to take the values
>>> of
>>> the text fields in the form and put them into an array, then be able to
>>> display the values in that array on index.php Does anyone know how I
>>> would
>>> do that?
>>>
>>> Here is my form...
>>>
>>> <form action="index.php" method="post">
>>> <table>
>>>   <tr>
>>>     <td>Option1</td>
>>>     <td><input type="text" name="option[]" /></td>
>>>   </tr>
>>>   <tr>
>>>     <td>Option2</td>
>>>     <td><input type="text" name="option[]" /></td>
>>>   </tr>
>>>   <tr>
>>>     <td></td>
>>>     <td><input value=submit" name="submit" type="submit" /></td>
>>>   </tr>
>>> </table>
>>> </table></form>
>>
>> You'll find they are already in an array which you can access as
>> $_POST['option'] - from there foreach() should be the next step.
>>
>>
>> Cheers
>> --
>> David Robley
>>
>> Polls show that 9 out of 6 schizophrenics agree.
>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> I am new to programming. How would I use foreach()to display the entries
> in the array?

You could read TFM which has an example -
http://php.net/manual/en/control-structures.foreach.php


Cheers
-- 
David Robley

Why are you wasting time reading taglines?
Today is Setting Orange, the 59th day of Confusion in the YOLD 3175. 


--- End Message ---
--- Begin Message ---
> Jason Carson wrote:
>
>>> Jason Carson wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> Lets say I have a file called form.php with the following form on it
>>>> that
>>>> redirects to index.php when submitted. I would like to take the values
>>>> of
>>>> the text fields in the form and put them into an array, then be able
>>>> to
>>>> display the values in that array on index.php Does anyone know how I
>>>> would
>>>> do that?
>>>>
>>>> Here is my form...
>>>>
>>>> <form action="index.php" method="post">
>>>> <table>
>>>>   <tr>
>>>>     <td>Option1</td>
>>>>     <td><input type="text" name="option[]" /></td>
>>>>   </tr>
>>>>   <tr>
>>>>     <td>Option2</td>
>>>>     <td><input type="text" name="option[]" /></td>
>>>>   </tr>
>>>>   <tr>
>>>>     <td></td>
>>>>     <td><input value=submit" name="submit" type="submit" /></td>
>>>>   </tr>
>>>> </table>
>>>> </table></form>
>>>
>>> You'll find they are already in an array which you can access as
>>> $_POST['option'] - from there foreach() should be the next step.
>>>
>>>
>>> Cheers
>>> --
>>> David Robley
>>>
>>> Polls show that 9 out of 6 schizophrenics agree.
>>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> I am new to programming. How would I use foreach()to display the entries
>> in the array?
>
> You could read TFM which has an example -
> http://php.net/manual/en/control-structures.foreach.php
>
>
> Cheers
> --
> David Robley
>
> Why are you wasting time reading taglines?
> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
What I currently have is...

foreach ($_POST['option'] as $value) {
    echo "Value: $value<br />\n";
}

...but that doesn't work. TFM didn't help me :-(


--- End Message ---
--- Begin Message ---
Did you correct the missing double quote in your sending form first?

Warren Vail

-----Original Message-----
From: Jason Carson [mailto:[email protected]] 
Sent: Thursday, July 23, 2009 9:33 PM
To: [email protected]
Subject: Re: [PHP] Re: A form and an array

> Jason Carson wrote:
>
>>> Jason Carson wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> Lets say I have a file called form.php with the following form on it
>>>> that
>>>> redirects to index.php when submitted. I would like to take the values
>>>> of
>>>> the text fields in the form and put them into an array, then be able
>>>> to
>>>> display the values in that array on index.php Does anyone know how I
>>>> would
>>>> do that?
>>>>
>>>> Here is my form...
>>>>
>>>> <form action="index.php" method="post">
>>>> <table>
>>>>   <tr>
>>>>     <td>Option1</td>
>>>>     <td><input type="text" name="option[]" /></td>
>>>>   </tr>
>>>>   <tr>
>>>>     <td>Option2</td>
>>>>     <td><input type="text" name="option[]" /></td>
>>>>   </tr>
>>>>   <tr>
>>>>     <td></td>
>>>>     <td><input value=submit" name="submit" type="submit" /></td>
>>>>   </tr>
>>>> </table>
>>>> </table></form>
>>>
>>> You'll find they are already in an array which you can access as
>>> $_POST['option'] - from there foreach() should be the next step.
>>>
>>>
>>> Cheers
>>> --
>>> David Robley
>>>
>>> Polls show that 9 out of 6 schizophrenics agree.
>>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> I am new to programming. How would I use foreach()to display the entries
>> in the array?
>
> You could read TFM which has an example -
> http://php.net/manual/en/control-structures.foreach.php
>
>
> Cheers
> --
> David Robley
>
> Why are you wasting time reading taglines?
> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
What I currently have is...

foreach ($_POST['option'] as $value) {
    echo "Value: $value<br />\n";
}

...but that doesn't work. TFM didn't help me :-(


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Yes

> Did you correct the missing double quote in your sending form first?
>
> Warren Vail
>
> -----Original Message-----
> From: Jason Carson [mailto:[email protected]]
> Sent: Thursday, July 23, 2009 9:33 PM
> To: [email protected]
> Subject: Re: [PHP] Re: A form and an array
>
>> Jason Carson wrote:
>>
>>>> Jason Carson wrote:
>>>>
>>>>> Hello everyone,
>>>>>
>>>>> Lets say I have a file called form.php with the following form on it
>>>>> that
>>>>> redirects to index.php when submitted. I would like to take the
>>>>> values
>>>>> of
>>>>> the text fields in the form and put them into an array, then be able
>>>>> to
>>>>> display the values in that array on index.php Does anyone know how I
>>>>> would
>>>>> do that?
>>>>>
>>>>> Here is my form...
>>>>>
>>>>> <form action="index.php" method="post">
>>>>> <table>
>>>>>   <tr>
>>>>>     <td>Option1</td>
>>>>>     <td><input type="text" name="option[]" /></td>
>>>>>   </tr>
>>>>>   <tr>
>>>>>     <td>Option2</td>
>>>>>     <td><input type="text" name="option[]" /></td>
>>>>>   </tr>
>>>>>   <tr>
>>>>>     <td></td>
>>>>>     <td><input value=submit" name="submit" type="submit" /></td>
>>>>>   </tr>
>>>>> </table>
>>>>> </table></form>
>>>>
>>>> You'll find they are already in an array which you can access as
>>>> $_POST['option'] - from there foreach() should be the next step.
>>>>
>>>>
>>>> Cheers
>>>> --
>>>> David Robley
>>>>
>>>> Polls show that 9 out of 6 schizophrenics agree.
>>>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> I am new to programming. How would I use foreach()to display the
>>> entries
>>> in the array?
>>
>> You could read TFM which has an example -
>> http://php.net/manual/en/control-structures.foreach.php
>>
>>
>> Cheers
>> --
>> David Robley
>>
>> Why are you wasting time reading taglines?
>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> What I currently have is...
>
> foreach ($_POST['option'] as $value) {
>     echo "Value: $value<br />\n";
> }
>
> ...but that doesn't work. TFM didn't help me :-(
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--- End Message ---
--- Begin Message ---
In php.ini turn the "display_errors" to "on".
If any error,warn or notice shown,copy them and paste here.
So you can tell us what doesn't work.

good luck~

2009/7/24 Jason Carson <[email protected]>

> > Jason Carson wrote:
> >
> >>> Jason Carson wrote:
> >>>
> >>>> Hello everyone,
> >>>>
> >>>> Lets say I have a file called form.php with the following form on it
> >>>> that
> >>>> redirects to index.php when submitted. I would like to take the values
> >>>> of
> >>>> the text fields in the form and put them into an array, then be able
> >>>> to
> >>>> display the values in that array on index.php Does anyone know how I
> >>>> would
> >>>> do that?
> >>>>
> >>>> Here is my form...
> >>>>
> >>>> <form action="index.php" method="post">
> >>>> <table>
> >>>>   <tr>
> >>>>     <td>Option1</td>
> >>>>     <td><input type="text" name="option[]" /></td>
> >>>>   </tr>
> >>>>   <tr>
> >>>>     <td>Option2</td>
> >>>>     <td><input type="text" name="option[]" /></td>
> >>>>   </tr>
> >>>>   <tr>
> >>>>     <td></td>
> >>>>     <td><input value=submit" name="submit" type="submit" /></td>
> >>>>   </tr>
> >>>> </table>
> >>>> </table></form>
> >>>
> >>> You'll find they are already in an array which you can access as
> >>> $_POST['option'] - from there foreach() should be the next step.
> >>>
> >>>
> >>> Cheers
> >>> --
> >>> David Robley
> >>>
> >>> Polls show that 9 out of 6 schizophrenics agree.
> >>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >> I am new to programming. How would I use foreach()to display the entries
> >> in the array?
> >
> > You could read TFM which has an example -
> > http://php.net/manual/en/control-structures.foreach.php
> >
> >
> > Cheers
> > --
> > David Robley
> >
> > Why are you wasting time reading taglines?
> > Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> What I currently have is...
>
> foreach ($_POST['option'] as $value) {
>    echo "Value: $value<br />\n";
> }
>
> ...but that doesn't work. TFM didn't help me :-(
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
I have it working now. I had a comma where a semicolon should have been.

Silly error on my part but thanks to everyone who tried to help me.

> In php.ini turn the "display_errors" to "on".
> If any error,warn or notice shown,copy them and paste here.
> So you can tell us what doesn't work.
>
> good luck~
>
> 2009/7/24 Jason Carson <[email protected]>
>
>> > Jason Carson wrote:
>> >
>> >>> Jason Carson wrote:
>> >>>
>> >>>> Hello everyone,
>> >>>>
>> >>>> Lets say I have a file called form.php with the following form on
>> it
>> >>>> that
>> >>>> redirects to index.php when submitted. I would like to take the
>> values
>> >>>> of
>> >>>> the text fields in the form and put them into an array, then be
>> able
>> >>>> to
>> >>>> display the values in that array on index.php Does anyone know how
>> I
>> >>>> would
>> >>>> do that?
>> >>>>
>> >>>> Here is my form...
>> >>>>
>> >>>> <form action="index.php" method="post">
>> >>>> <table>
>> >>>>   <tr>
>> >>>>     <td>Option1</td>
>> >>>>     <td><input type="text" name="option[]" /></td>
>> >>>>   </tr>
>> >>>>   <tr>
>> >>>>     <td>Option2</td>
>> >>>>     <td><input type="text" name="option[]" /></td>
>> >>>>   </tr>
>> >>>>   <tr>
>> >>>>     <td></td>
>> >>>>     <td><input value=submit" name="submit" type="submit" /></td>
>> >>>>   </tr>
>> >>>> </table>
>> >>>> </table></form>
>> >>>
>> >>> You'll find they are already in an array which you can access as
>> >>> $_POST['option'] - from there foreach() should be the next step.
>> >>>
>> >>>
>> >>> Cheers
>> >>> --
>> >>> David Robley
>> >>>
>> >>> Polls show that 9 out of 6 schizophrenics agree.
>> >>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>> >>>
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>>
>> >>>
>> >> I am new to programming. How would I use foreach()to display the
>> entries
>> >> in the array?
>> >
>> > You could read TFM which has an example -
>> > http://php.net/manual/en/control-structures.foreach.php
>> >
>> >
>> > Cheers
>> > --
>> > David Robley
>> >
>> > Why are you wasting time reading taglines?
>> > Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>> What I currently have is...
>>
>> foreach ($_POST['option'] as $value) {
>>    echo "Value: $value<br />\n";
>> }
>>
>> ...but that doesn't work. TFM didn't help me :-(
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>



--- End Message ---
--- Begin Message ---
See http://bugs.php.net/?id=48612

"Thank you for taking the time to write to us, but this is not
a bug. And RTFM". (RTFM is my interpretation of the rest).

And that only took a little more than a month. Thanks very much.

Can anyone here tell me why the CLI behaviour reported is not a bug?  An
explicit manual reference will do. 

Btw, I brought it up here already:
http://marc.info/?l=php-general&m=124487699630514&w=2


/Per

-- 
Per Jessen, Zürich (23.1°C)


--- End Message ---

Reply via email to