Re: PHP Notice: Undefined index

From: Date: Mon, 22 May 2006 20:41:41 +0000
Subject: Re: PHP Notice: Undefined index
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236674@lists.php.net to get a copy of this message
On Fri, May 19, 2006 6:08 pm, John Taylor-Johnston wrote: > Any idea why this bit of code > > if("yes" == $_POST['submitter']) > { > mysql_select_db($db,$myconnection); > > $sql = "INSERT INTO > $db.$table > (name,email,comments,entrydate) > values > ('$name','$email','$comments','$entrydate')"; > mysql_query($sql) or die(print mysql_error()); > } > > is provoking this message in my Apache error log? > > [Fri May 19 19:05:10 2006] [error] PHP Notice: Undefined index: > submitter in > /home/jtjohnston/domains/jtjohnston.ca/public_html/comments.php on > line 29 Because $_POST['submitter'] is not set? Because your script assumes it IS set? Because sometimes your script is called to display the form, before $_POST['submitter'] has anything in it, and sometimes it's called after they hit submit and it has something in it? if (isset($_POST['submitter']) && "yes" == $_POST['submitter']){ http://php.net/isset -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#236674) next »