Error in Internet-explorer, when retrieving data from mysql database (but works in firefox)

Go To


i wrote in file showList.php the following form, which select items from the database and show them in drop-down list:

<form id="selForm" name="selForm" action="index.php" method="post">
<select name="selection" id="selection">
<option id="nothingSelected" >--Choose form---></option>

if (!$con)
  die('Could not connect: ' . mysql_error());
$result = mysql_query("SELECT * FROM formsTable");

while($row = mysql_fetch_array($result))
  echo "<option  id='$selection_id' name=\"sectionid\"  value='$selection_id' >";
  echo $row['nummer'] . " " . $row['titel']. " ";
  echo "</option>";

<input type="button" value="load form" onClick="validateForm(document.selForm)">
<input type="button" value="delete form" onClick="deleteForm(document.selForm);">

I include this file in index.php as follows:

<?php include('showList.php');?>

Now when I call index.php, a list of found forms will be displayed in a drop-down list.

This works fine in firefox, my Problem is when I call index.php in internetexplorer, I get the following error:

Notice: Undefined index: selection in C:\path\showList.php on line 43

Line 43 is:


as you can see in the form above. Any idea?

2012-04-04 16:40
by Max_Salah
perhaps provide a blank space after ) - hjpotter92 2012-04-04 16:43
You have a ">" in the content of . This could be breaking the element in IE and causing the element not to be submitted to your script - pharalia 2012-04-04 16:44
test if $_POST['selection'] exists with isset() to begin wit - b1onic 2012-04-04 16:45
Does your website pass the W3C validation without any errors and warnings? Unless not, I won't start to worry about differences between browsers as the HTML is not valid - hakre 2012-04-04 16:48
ok I tried this


and it works.. thank you all for your hel - Max_Salah 2012-04-04 16:52


You need to change the problem line from:



if(isset($_POST['selection']) && ($_POST['selection']==$selection_id))

to check that a value for (as @b1onic suggested).

Obviously nothing will be POSTed the first time the form is shown in the browser - whichever browser you are using - so you will get that error.

2012-04-04 16:55
by Annabel


Seems that your php script are trying to read the 'selection' in your $_POST variable but it wasn't defined yet.

Replace that line:


To that:

if(array_key_exists('selection', $_POST) && $_POST['selection'] == $selection_id)


if(isset($_POST['selection']) && $_POST['selection'] == $selection_id) 

This should make fix your warning and there are differences between the array_key_exists. In this case, use isset() because its faster and easier.

2012-04-04 16:54
by Igor Escobar