473,491 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

undefined index

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
5 10864
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
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2794
by: Coder Droid | last post by:
I decided to run some code with errors set to E_ALL, just to see what I would run across. It caught a few things, but 90% or better of the messages were of the 'undefined' kind: PHP Notice: ...
9
9589
by: petermichaux | last post by:
Hi, I am curious about how php deals with the following situation where I use an undefined index into an array. PHP seems to be behaving exactly how I want it to but I want to make sure that it...
4
7170
by: John Oliver | last post by:
PHP Notice: Undefined index: name in /home/www/reformcagunlaws.com/new.php on line 6 PHP Notice: Undefined index: address in /home/www/reformcagunlaws.com/new.php on line 7 PHP Notice: ...
9
1854
by: Alan Schroeder | last post by:
The following code produces the expected results on a PC using gcc, but I need to port it (or least something similar) to a different platform/compiler. I don't think I've introduced any undefined...
7
2193
by: deepak | last post by:
Using 'char' as an array index is an undefined behavior?
3
4954
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined...
3
5482
by: number1yan | last post by:
Can anyone help me, i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is: Notice:...
15
4444
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
5
7165
by: siyaverma | last post by:
Hi, I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that, After doing some changes when i run it on my...
3
3844
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.