Re: undefined index and php
| From: | ross at aztechost dot com | Date: | Thu, 10 Nov 2005 12:58:16 +0000 |
| Subject: | Re: undefined index and php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-225507@lists.php.net to get a copy of this message | ||
I have never really used this abreviated format before
why the question mark and the colon? What is the long hang eqivalent.
I turned magic quotes off too.
thanks.
R.
----- Original Message ----- From: "Jasper Bryant-Greene" <jasper@album.co.nz>
To: "Ross" <ross@aztechost.com>
Cc: <php-general@lists.php.net>
Sent: Thursday, November 10, 2005 12:19 PM
Subject: Re: [PHP] undefined index and php
Ross wrote:because the following line give the notice 'undefined index' BEFORE the submit button has been pressed.. <? $heading_insert= stripslashes($_POST['heading']);?>That's because before the submit button has been pressed, $_POST is empty and so 'heading' is indeed an undefined index. Try: $heading_insert = isset( $_POST['heading'] ) ? stripslashes( $_POST['heading'] ) : ''; By the way, while you're switching register_globals off, it might be a good idea to also switch off magic_quotes_gpc (the reason you need stripslashes() above) and short_open_tag (judging by your use of the non-portable <? open tag rather than <?php). Jasper