1

Input values

    <input type="hidden" name="service_row[1]['row']" value="1" />
    <input type="checkbox" name="service_row[1]['check']" />
    <input type="text" name="service_row[1]['observation']" />
    <input type="text" name="service_row[1]['parts']" />

Handler code

    foreach ($_POST['service_row'] as $data) {
        $row_num = $data['row'];
        if (isset($data['check'])) {
            $checked = 1;
        } else {
            $checked = 0;
        }
        $observation = database::escape($data['observation']);
        $parts = database::escape($data['parts']);
    }

My var dump on $data displays

    array
       ''row'' => string '1' (length=1)
       ''observation'' => string 'Test' (length=4)
       ''parts'' => string 'Test' (length=4)

So from what I can see is that the $data array exists and displays the values I have put in but for some reason when I try to put the data into a variable it returns null.

Can anyone see what I am not seeing here? Any help is much appreciated, this one got me stumped right now.

3
  • What is database::escape() doing? Is it returning correctly? Commented Apr 12, 2012 at 12:36
  • 1
    In your HTML form, remove the quotes from the array keys. service[1][row] etc... Commented Apr 12, 2012 at 12:39
  • @SnapGravy Be sure to mark Alexander's answer accepted below by clicking the checkmark. Commented Apr 12, 2012 at 12:54

1 Answer 1

3

I think that you must use index 'row' instead of row or remove quotes from your html.

Sign up to request clarification or add additional context in comments.

1 Comment

Removing the quotes fixed the issue. Thanks to Alexander and Michael for your quick response. Easy to go blind once in a while :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.