Re: [PHP] Problem retrieving $_POST values

2007-11-13 Thread Jon Westcot
Hi Chris, et al.:

> > Here's a section of what comes back when I do this:
> >
> > [mls] => 1234567
> > [property_address] => Main St
> > [city_arr] => Array
> > (
> > [0] => CHNDHT
> > [1] => CHNDLR
> > [2] => GILBER
> > [3] => HIGLEY
> > [4] => MESA
> > [5] => TEMPE
> > )
>
> So it is there :)
>
> print_r($_POST['city_arr']);

After much wringing of hands and gnashing of teeth, I found the problem.
Typo.  Of course.  I'd only read over the code about a hundred times before
I asked for help, if that's any consolation.

> > > > Is there some (free ) way to test a php script outside of a web
page?
> > >
> > > cmd line you can do:
> > >
> > > php -l /path/to/file.php
> >
> > Is this something I can access through SSH?  And will it show me
errors as the script executes?
>
> Oops, I thought you meant for parse errors. That won't tell you about
> anything else unfortunately.

Ah, don't "oops" anything!  That tip was worth its weight in gold to me!
In fact, it told me where one of the typos was that was causing a syntax
error during the initial parsing.  The other typo was more insidious (trying
to use count() as $count()), but just as deadly to the output.

Thanks for the great tips!

Jon

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



Re: [PHP] Problem retrieving $_POST values

2007-11-13 Thread Philip Thompson
On Nov 13, 2007 7:01 AM, chris smith <[EMAIL PROTECTED]> wrote:

> On Nov 13, 2007 7:10 PM, Jon Westcot <[EMAIL PROTECTED]> wrote:
> > Hi Chris:
> >
> > > Exactly as you have there.
> > >
> > > print_r($_POST);
> > >
> > > will show you everything.
> >
> > Here's a section of what comes back when I do this:
> >
> > [mls] => 1234567
> > [property_address] => Main St
> > [city_arr] => Array
> > (
> > [0] => CHNDHT
> > [1] => CHNDLR
> > [2] => GILBER
> > [3] => HIGLEY
> > [4] => MESA
> > [5] => TEMPE
> > )
>
> So it is there :)
>
> print_r($_POST['city_arr']);



You can use empty():



empty() will return false if the array is empty. http://www.php.net/empty


> > How are you creating the field in your form?
> >
> > The three fields mentioned above on the form are specified thus:
>
> 
> all looks good.
>
> > > > Is there some (free ) way to test a php script outside of a web
> page?
> > >
> > > cmd line you can do:
> > >
> > > php -l /path/to/file.php
> >
> > Is this something I can access through SSH?  And will it show me
> errors as the script executes?
>
> Oops, I thought you meant for parse errors. That won't tell you about
> anything else unfortunately.


Are you running on Windoze? If so, I have seen that it will not throw parse
errors - it will just show a blank page. And believe me, this has caused me
a huge deal of frustration. If this is the case, you may consider using an
editor that has syntax validation built in.

HTH
~Philip


Re: [PHP] Problem retrieving $_POST values

2007-11-13 Thread chris smith
On Nov 13, 2007 7:10 PM, Jon Westcot <[EMAIL PROTECTED]> wrote:
> Hi Chris:
>
> > Exactly as you have there.
> >
> > print_r($_POST);
> >
> > will show you everything.
>
> Here's a section of what comes back when I do this:
>
> [mls] => 1234567
> [property_address] => Main St
> [city_arr] => Array
> (
> [0] => CHNDHT
> [1] => CHNDLR
> [2] => GILBER
> [3] => HIGLEY
> [4] => MESA
> [5] => TEMPE
> )

So it is there :)

print_r($_POST['city_arr']);

> > How are you creating the field in your form?
>
> The three fields mentioned above on the form are specified thus:


all looks good.

> > > Is there some (free ) way to test a php script outside of a web page?
> >
> > cmd line you can do:
> >
> > php -l /path/to/file.php
>
> Is this something I can access through SSH?  And will it show me errors 
> as the script executes?

Oops, I thought you meant for parse errors. That won't tell you about
anything else unfortunately.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Problem retrieving $_POST values

2007-11-13 Thread Jon Westcot
Hi Chris:

> Exactly as you have there.
> 
> print_r($_POST);
> 
> will show you everything.

Here's a section of what comes back when I do this:

[mls] => 1234567
[property_address] => Main St
[city_arr] => Array
(
[0] => CHNDHT
[1] => CHNDLR
[2] => GILBER
[3] => HIGLEY
[4] => MESA
[5] => TEMPE
)
 
> How are you creating the field in your form?

The three fields mentioned above on the form are specified thus:

  MLS#: 
 
Address: 

  
  City: 

 CHNDHT
CHNDLR
GILBER
HIGLEY
MESA
TEMPE


 
> > Is there some (free ) way to test a php script outside of a web page?
> 
> cmd line you can do:
> 
> php -l /path/to/file.php

Is this something I can access through SSH?  And will it show me errors as 
the script executes?

Thanks for the suggestions!

Jon


Re: [PHP] Problem retrieving $_POST values

2007-11-12 Thread Chris

Jon Westcot wrote:

Hi all:

I'm having problems retrieving an array value that should be in a $_POST 
setting.  In fact, I'm having trouble with the code hanging with no warnings or 
errors whatsoever, so I've got no clue why it's not working.

Working code:

if(isset($_POST["mls"])) {
if(strlen(trim($_POST["mls"])) > 0) {
$query = "mls=" . $_POST["mls"];
}
}

Non-working code:

if(isset($_POST['city_arr'])) {
// This space intentionally left blank.
}

The only thing I know that is different is that "mls" is a single value and that 
city_arr is an array.  I have tried expressing it as "city_arr[]" with no success.

Does anyone have an example of how to reference the $_POST value when said 
value is an array?  I can't seem to find a sample of this anywhere in the 
manual.


Exactly as you have there.

print_r($_POST);

will show you everything.

How are you creating the field in your form?


Is there some (free ) way to test a php script outside of a web page?


cmd line you can do:

php -l /path/to/file.php

--
Postgresql & php tutorials
http://www.designmagick.com/

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



[PHP] Problem retrieving $_POST values

2007-11-12 Thread Jon Westcot
Hi all:

I'm having problems retrieving an array value that should be in a $_POST 
setting.  In fact, I'm having trouble with the code hanging with no warnings or 
errors whatsoever, so I've got no clue why it's not working.

Working code:

if(isset($_POST["mls"])) {
if(strlen(trim($_POST["mls"])) > 0) {
$query = "mls=" . $_POST["mls"];
}
}

Non-working code:

if(isset($_POST['city_arr'])) {
// This space intentionally left blank.
}

The only thing I know that is different is that "mls" is a single value and 
that city_arr is an array.  I have tried expressing it as "city_arr[]" with no 
success.

Does anyone have an example of how to reference the $_POST value when said 
value is an array?  I can't seem to find a sample of this anywhere in the 
manual.

While I'm on the subject, how can I get a php page to tell me where a 
syntax error exists if one does instead of just giving me a blank page?  Is 
there some (free ) way to test a php script outside of a web page?

Thanks!

Jon