Hi all,

PHP newbie here.

I have a contact form I'm trying to get up and running, but when go browse to the URL I'm getting this error:

'Warning: array_key_exists(): The second argument should be either an array or an object in'

I do not know PHP, but I copy and pasted the code from one of my other sites (which has the same form and it works great) but this one is acting up.

The URL is http://feedyoursoul.org/join1.php

Thanks for any suggestions.

    We need to see the code, particularly where the error is.

      I'm not sure where the error is, because when you go to the URL, it's saying it's on line 182.

      But here's the section of code, with <?php being line 182.

      <?php
      if(!array_key_exists('formMessage', $SESSION))
      $
      SESSION['formMessage'] = "";
      if(!array_key_exists('form_element0', $SESSION))
      $
      SESSION['form_element0'] = "";
      if(!array_key_exists('form_element1', $SESSION))
      $
      SESSION['form_element1'] = "";
      if(!array_key_exists('form_element2', $SESSION))
      $
      SESSION['form_element2'] = "";
      ?>

      Should I post all the code, all 300 lines or so?

      Thanks for the reply.

        It gives that error to you because $SESSION is empty and it isnt an array yet. Theres no need to use array_key_exists funtion at all. Use isset instead:

        if (!isset($_SESSION['formMessage'])) {
            $_SESSION['formMessage'] = '';
        }
        

        BTW, use the code tags to give us better output on the code side(like I did). Its much more nicer to help.

        http://www.phpbuilder.com/board/misc.php?do=bbcode

          cahva wrote:

          BTW, use the code tags to give us better output on the code side(like I did). Its much more nicer to help.

          No prob.

          So should I use isset on all four sessions, or just the first?

          Thanks.

            Okay, I changed all the array_key_exists funtion to isset but now I'm getting a Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_VARIABLE or '$' in /home/content/f/e/e/feedyoursoul/html/join1.php on line 183 error!

              Anyone have any ideas on my new error message?

                Show us the code around 183 again and the PHP block before that too.

                  I got tired of all these weird errors so I started from scratch and created a new form and all is working now.

                  Thanks anyways guys.

                    Write a Reply...