MySQL query not recognizing variables passed to parameter array

I am processing output from a form, but I keep getting "Undefined variable" for the variables I have assigned to my query parameter array.

Error message:
Error Number: 8
TEXT: Undefined variable: ParentGuardianLastNameJP
LOCATION: /Applications/MAMP/htdocs/eng_adv_v2/business/contact.php, line 82, at April 25, 2011, 6:53 am
Showing backtrace:
Contact.UpdateParent("459", "¿¿¿¿", "¿¿¿", "Karl", "Pisor", "03-5696-2577", "080-3276-4570", "", "134-0085", "1", "Edogawa-ku", "Minami Kasai 5-5-18-401", "") # line   93, file: /Applications/MAMP/htdocs/eng_adv_v2/template_process.php

...the same message is for all of the passed variables...

Here's the PHP in template_process.php:

        // initialize error message
      $error_msg = '';
      // update parent record
      if (isset($_POST['RegSubmit'])) {
            // get the user-entered data
            $ParentGuardianPK = $_SESSION['ParentId'];
            $ParentGuardianLastNameJP = trim($_POST['ParentGuardianLastNameJP']);
            $ParentGuardianFirstNameJP = trim($_POST['ParentGuardianFirstNameJP']);
            $ParentGuardianFirstNameEN = trim($_POST['ParentGuardianFirstNameEN']);
            $ParentGuardianLastNameEN = trim($_POST['ParentGuardianLastNameEN']);
            $ParentGuardianPhone = trim($_POST['ParentGuardianPhone']);
            $ParentGuardianEmerPhone = trim($_POST['ParentGuardianEmerPhone']);
            $ParentGuardianEmail = trim($_POST['ParentGuardianEmail']);
            $ParentGuardianPostalCode = trim($_POST['ParentGuardianPostalCode']);
            $ParentGuardianPrefectureFK = trim($_POST['ParentGuardianPrefectureFK']);
            $ParentGuardianCityTown = trim($_POST['ParentGuardianCityTown']);
            $ParentGuardianAddress1 = trim($_POST['ParentGuardianAddress1']);
            $ParentGuardianAddress2 = trim($_POST['ParentGuardianAddress2']);
            // server-side validation on name entry
            if (!empty($ParentGuardianFirstNameEN) && !empty($ParentGuardianLastNameEN)) {
                  // process update
                  $updateParentResult = Contact::UpdateParent(
                  // update is okay
                  if ($updateParentResult) {
                        $error_msg = 'Update executed correctly';
                  } else {
                        // query returns 0 results. Throw error.
                        $error_msg = 'Error with update';
            } else {
                  // this generic error is testing the client-side validation again
                  $error_msg = $AdminLoginError_FormError;
            } // end server-side validation
      } // end RegSubmit

Here's my query setup in contact.php:

public static function UpdateParent()
                  // Write SQL statement
                  $sql = 'CALL contact_update_parent(
                  // Build the parameters array
                  $params = array(
                                      ':pk_contact' => $ParentGuardianPK,
                                      ':lastname_jp' => $ParentGuardianLastNameJP,
                                      ':firstname_jp' => $ParentGuardianFirstNameJP,
                                      ':firstname_en' => $ParentGuardianFirstNameEN,
                                      ':lastname_en' => $ParentGuardianLastNameEN,
                                      ':phone' => $ParentGuardianPhone,
                                      ':emergency_phone' => $ParentGuardianEmerPhone,
                                      ':email' => $ParentGuardianEmail,
                                      ':postalcode' => $ParentGuardianPostalCode,
                                      ':fk_prefecture' => $ParentGuardianPrefectureFK,
                                      ':city_town' => $ParentGuardianCityTown,
                                      ':address1' => $ParentGuardianAddress1,
                                      ':address2' => $ParentGuardianAddress2);              
                  // Execute the query and return the results
                  return DatabaseHandler::Execute($sql, $params);

Here's the SQL:

PROCEDURE contact_update_parent
  UPDATE contact
  t_lastname_jp = inLastNameJP,
  t_firstname_jp = inFirstNameJP,
  t_firstname_en = inFirstNameEN,
  t_lastname_en = inLastNameEN,
  t_phone = inPhone,
  t_phone_emergency = inPhoneEmergency,
  t_email = inEmail,
  t_postalcode = inPostalCode,
  fk_prefecture = inPrefectureFK,
  t_city = inCity,
  t_address1 = inAddress1,
  t_address2 = inAddress2
  WHERE  pk_contact = inParentPK;
  IN inParentPK int(10),
  IN inLastNameJP varchar(255),
  IN inFirstNameJP varchar(255),
  IN inFirstNameEN varchar(255),
  IN inLastNameEN varchar(255),
  IN inEmail varchar(100),
  IN inPhone varchar(50),
  IN inPhoneEmergency varchar(50),
  IN inPostalCode varchar(30),
  IN inPrefectureFK int(10),
  IN inCity varchar(100),
  IN inAddress1 varchar(100),
  IN inAddress2 varchar(100)

Who is Participating?
johanntagleConnect With a Mentor Commented:
I'm not a PHP programmer but it looks like the problem is not in MySQL but the PHP code.  Shouldn't there be parameters inside the parentheses in the line below in contact.php?  That's usually the case for function definitions in the languages I use.

public static function UpdateParent()
kpisorAuthor Commented:
Perfect. I just didn't declare the parameters in the function. I fixed that and it worked first time. Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.