By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

undefined index

P: n/a
getting errors

Notice: Undefined index: name in F:\uni\Software
engineering\assignment4\guestbook.php on line 6

the variable $name is declared as $name = _POST["name"];

What could be causing this?

I've recently installed php 5 on IIS with mysql 4. All running on windows XP

downloaded code straight from my uni's tute site.

went to run it and it sort of runs but I get these errors at the top of the
page.

Thanks

Karl.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
While the city slept, news.bigpond.com (kh*******@bigpond.com) feverishly
typed...
getting errors

Notice: Undefined index: name in F:\uni\Software
engineering\assignment4\guestbook.php on line 6

the variable $name is declared as $name = _POST["name"];


Is this a typo in your post? Or does it appear *exactly* the same in your
code? It should be $name = $_POST["name"];

Cheers,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. ni***@DOG.nigenet.org.uk, take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!
Jul 17 '05 #2

P: n/a
"news.bigpond.com" <kh*******@bigpond.com> wrote in message
news:%n******************@news-server.bigpond.net.au...
getting errors

Notice: Undefined index: name in F:\uni\Software
engineering\assignment4\guestbook.php on line 6

the variable $name is declared as $name = _POST["name"];

What could be causing this?

I've recently installed php 5 on IIS with mysql 4. All running on windows XP
downloaded code straight from my uni's tute site.

went to run it and it sort of runs but I get these errors at the top of the page.

Thanks

Karl.


In $_POST['name'], 'name' is the undefined index if no 'name' has been
POSTed. For example, if you have a form whose action is itself, and in the
form php file you refer to $_POST['name'], 'name' is undefined until the
form is submitted.

- JP
Jul 17 '05 #3

P: n/a
On Mon, 13 Sep 2004 17:48:54 GMT, "kingofkolt"
<je**********@comcast.net> wrote:
"news.bigpond.com" <kh*******@bigpond.com> wrote in message
news:%n******************@news-server.bigpond.net.au...
getting errors

Notice: Undefined index: name in F:\uni\Software
engineering\assignment4\guestbook.php on line 6

the variable $name is declared as $name = _POST["name"];

What could be causing this?

I've recently installed php 5 on IIS with mysql 4. All running on windows

XP

downloaded code straight from my uni's tute site.

went to run it and it sort of runs but I get these errors at the top of

the
page.

Thanks

Karl.


In $_POST['name'], 'name' is the undefined index if no 'name' has been
POSTed. For example, if you have a form whose action is itself, and in the
form php file you refer to $_POST['name'], 'name' is undefined until the
form is submitted.

- JP

PHP5 requires some extra checks AFAIU. You'll now need to use code such
as:
if (isset($_POST['name'])) {
/* do something with $_POST['name']... */
} else {
/* $_POST['name'] is undefined */
}
HTH =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #4

P: n/a
Ian.H <ia*@windozedigiserv.net> wrote:
if (isset($_POST['name'])) {
/* do something with $_POST['name']... */
} else {
/* $_POST['name'] is undefined */
}


array_key_exists would be better in general...

From http://nl2.php.net/array_key_exists
"Example 2. array_key_exists() vs isset()

isset() does not return TRUE for array keys that correspond to a NULL
value, while array_key_exists() does.
<?php
$search_array = array('first' => null, 'second' => 4);

// returns false
isset($search_array['first'])

// returns true
array_key_exists('first', $search_array);
?>"

The chance of null values in POST/GET is quite minimal though :)

--

Daniel Tryba

Jul 17 '05 #5

P: n/a
On Mon, 13 Sep 2004 20:42:21 +0000 (UTC), Daniel Tryba
<ne****************@canopus.nl> wrote:
Ian.H <ia*@windozedigiserv.net> wrote:
if (isset($_POST['name'])) {
/* do something with $_POST['name']... */
} else {
/* $_POST['name'] is undefined */
}


array_key_exists would be better in general...

From http://nl2.php.net/array_key_exists
"Example 2. array_key_exists() vs isset()

isset() does not return TRUE for array keys that correspond to a NULL
value, while array_key_exists() does.
<?php
$search_array = array('first' => null, 'second' => 4);

// returns false
isset($search_array['first'])

// returns true
array_key_exists('first', $search_array);
?>"

The chance of null values in POST/GET is quite minimal though :)

Ahh good point.. while true, you never know and if you can cater for
it........... =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.