Advertisement

04.21.2006 at 12:38AM PDT, ID: 21821912
[x]
Attachment Details

PHP Beginner: Updateing a record from database

Asked by luna621 in PHP and Databases

Tags: getrequestvalue, php

I got the update to work, but I'm getting these warnings/errors at the top of the webpage:

Error, unable to update database:
Unknown column 'person_id' in 'where clause'

It's strange because the database DOES get updated...

--------------------------------------------------------------------------

<?php
error_reporting(E_ALL);
session_start();
  header("Pragma: no-cache");

  include("util.php");
      securityCheck();

      $locationFeedback = "&nbsp;";
      $feedback = "&nbsp;";

      $isPostback = FALSE;
  if (array_key_exists("Submit", $_REQUEST)) {
    $isPostback = TRUE;
  }

  if ($isPostback) {

      $person_id = $_SESSION["LoggedOnPersonId"];
        $password = getRequestValue("password");
        $firstname = getRequestValue("firstname");
        $middlename = getRequestValue("middlename");
        $lastname = getRequestValue("lastname");
        $employer = getRequestValue("employer");
        $graduation_date = getRequestValue("graduation_date");
        $subnewsletter = getRequestValue("subnewsletter");
        $email_address = getRequestValue("email_address");
        $phone_number = getRequestValue("phone_number");

            $validated = true;

            if ($validated) {

          $sql = Array();
          $res = Array();
          $last_ids = Array();
          $delquery = Array();


          $sql[0] = "UPDATE person SET password = '$password', firstname = '$firstname', middlename = '$middlename', lastname = '$lastname' WHERE person_id = '$person_id'";
          $sql[1] = "UPDATE member SET employer = '$employer', graduation_date = '$graduation_date', subnewsletter = '$subnewsletter', email_address = '$email_address' WHERE person_id = '$person_id'";
          $sql[2] = "UPDATE phone SET phone_number = '$phone_number' WHERE person_id = '$person_id'";

          $delquery[0] = "DELETE FROM person WHERE person_id = ";
          $delquery[1] = "DELETE FROM member WHERE person_id = ";
          $delquery[2] = "DELETE FROM phone WHERE phone_id = ";

          // print_r ($sql);

          $conn = getConnection();
          $feedback = "Member updated successfully.";

          for ($i = 0; $i < count($sql); ++$i) {
            $res[$i] = mysql_query($sql[$i], $conn);
            $last_ids[$i] = mysql_insert_id($conn);
            if (!$res[$i]) {
              $err = mysql_error ($conn);
              for ($j = $i-1; $j >= 0; -- $j) {
                mysql_query($delquery[$j] . $last_ids[$j]);
              }
              $feedback = "Error, unable to update database: <br />$err";
              break;
                }
              }
       }

echo $feedback;
}
?>



Thank you for any help. :-)Start Free Trial
[+][-]04.21.2006 at 12:40AM PDT, ID: 16505220

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 12:50AM PDT, ID: 16505258

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP and Databases
Tags: getrequestvalue, php
Sign Up Now!
Solution Provided By: RQuadling
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.21.2006 at 12:55AM PDT, ID: 16505279

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 12:55AM PDT, ID: 16505281

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:13AM PDT, ID: 16505349

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:14AM PDT, ID: 16505353

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:15AM PDT, ID: 16505359

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:16AM PDT, ID: 16505362

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:16AM PDT, ID: 16505363

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:19AM PDT, ID: 16505376

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:20AM PDT, ID: 16505382

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:22AM PDT, ID: 16505392

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:22AM PDT, ID: 16505393

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:38AM PDT, ID: 16505448

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:42AM PDT, ID: 16505466

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:48AM PDT, ID: 16505485

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:48AM PDT, ID: 16505487

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:49AM PDT, ID: 16505489

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:50AM PDT, ID: 16505497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:51AM PDT, ID: 16505498

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:53AM PDT, ID: 16505504

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:57AM PDT, ID: 16505523

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 01:59AM PDT, ID: 16505529

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 02:03AM PDT, ID: 16505543

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 02:34AM PDT, ID: 16505692

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 02:36AM PDT, ID: 16505705

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2006 at 02:40AM PDT, ID: 16505723

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32