468,283 Members | 1,914 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

Why wont this access an array???

Can someone please tell me how to access elements from a multiple
selection list? From what ive read on other posts, this is correct. I
keep getting an "Undefined variable" error though...

Form page********************************************** **************
<form action="/process.php" method="get" name="formOne" id="formOne">
<select name="owner[]" size="6" multiple id="owner[]">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form>
Process page********************************************** ************
for($i=0; $i < count($owner); $i++) {
echo $owner[$i];
}

Thanks! -Nick
Jul 16 '05 #1
2 2419
Nick wrote:
Process page********************************************** ************
for($i=0; $i < count($owner); $i++) {
echo $owner[$i];
}

Thanks! -Nick


replace echo $owner[$i];

with

echo $_GET["owner"][$i];

- Marcus
Jul 16 '05 #2
Nick wrote:
Can someone please tell me how to access elements from a multiple
selection list? From what ive read on other posts, this is correct. I
keep getting an "Undefined variable" error though...

Form page********************************************** **************
<form action="/process.php" method="get" name="formOne" id="formOne">
<select name="owner[]" size="6" multiple id="owner[]">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
<input type="submit" name="Submit" value="Submit">
</form> Process page********************************************** ************
for($i=0; $i < count($owner); $i++) {
echo $owner[$i];
}


Just a hunch... Have you defined the variable $owner? If not, you are
probably depending on register_globals to being "on", which it may not
be in your system. Try using the following:
$owner = $_GET["owner"];
before your for... loop.

HTH
--
Marius

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Steve Westwood | last post: by
4 posts views Thread by ben | last post: by
7 posts views Thread by Christine | last post: by
7 posts views Thread by dhnriverside | last post: by
3 posts views Thread by Brian Henry | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.