Re: MySQL novice: database not updating ... LONG

From: Date: Wed, 28 Feb 2001 13:37:50 +0000
Subject: Re: MySQL novice: database not updating ... LONG
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7013@lists.php.net to get a copy of this message
Three things I see: 1. You seem to be assigning hard-coded values to u_mange_users, and "0" , as it is last, will always win. I think, I alsway have to mess with them a bit. That's why checking your SQL is important. 2. You are embedding a semi-colon in SQL statements. That's not necessary. 3. Have you echoed the SQL statement to see if it is what you expect? Add "echo $query;" to print the query out to your browser. If you can, check it at the MySQL command line. Hope this helps - Miles At 12:19 PM 2/28/01 +0000, V e r b a l wrote:
I'm trying to modify a script I'm using. I've gotten so far that it displays my change and updates to old setting. I've added the required field in the database and all setting but my new addition are being updated. Anyone sees anything strange here, or failing that what should I look for in the code? V e r b a l 8< -------------------------- c o d e ----------------------------->8 Now, in the snippets I've included below. There are several more of these (<input lines are on one line rather than broken like here): <tr>
          <td width="50%" valign=center align=right>
            <font size=3>Manage Users:</font>
          </td>
          <?
          if ($u_manage_users==1) {
            $manageusersgrant="checked";
          }
          else {
            $manageusersdontgrant="checked";
          }
          ?>
          <td width="25%" valign=center align=center>
            <input type="radio" name="u_manage_users" value="1" <?echo
$manageusersgrant;?>>
          </td>
          <td width="25%" valign=center align=center>
            <input type="radio" name="u_manage_users" value="0" <?echo
$manageusersdontgrant;?>>
          </td>
        </tr>
// This is what I've included
        <tr>
          <td width="50%" valign=center align=right>
            <font size=3>Manage Clients:</font>
          </td>
          <?
            if ($u_manage_clients==1) {
                $manageclientsgrant="checked";
            }
            else {
                $manageclientsdontgrant="checked";
            }
           ?>
          <td width="25%" valign=center align=center>
                <input type="radio" name="u_manage_clients" value="1"
<? echo $manageclientsgrant;?>>
          </td>
          <td width="25%" valign=center align=center>
                <input type="radio" name="u_manage_clients" value="0"
<? echo $manageclientsdontgrant;?>>
          </td>
          </tr>
// Ends my addition The update is (as I understand) called by this statement .. <p align=center>
      <center>
      <input type="submit" value="Next >>"
name="cmdSelectDepartments">
      </td>
      </center>
And the routine called cmdSelectDepartments looks like this: if(isset($cmdSelectDepartments)) {
      $query = "UPDATE security SET ";
      $query .= "s_firstname='$txtFirstname', ";
      $query .= "s_lastname='$txtLastname', ";
      $query .= "s_password='$txtPassword', ";
      $query .= "s_email='$txtEmail' ";
      $query .= "WHERE s_user='$txtUsername';";
      $mysql_result = mysql_query($query, $mysql_link);
      if ($mysql_result) { }
      $query = "UPDATE security SET ";
      $query .= "s_register_new_tickets='$u_register_new_tickets', ";
      $query .= "s_authorize_tickets='$u_authorize_tickets', ";
      $query .= "s_assign_tickets='$u_assign_tickets', ";
      $query .= "s_update_tickets='$u_update_tickets', ";
      $query .= "s_delete_tickets='$u_delete_tickets', ";
      $query .= "s_open_closed_tickets='$u_open_closed_tickets', ";
      $query .=
"s_view_unauthorized_tickets='$u_view_unauthorized_tickets', ";
      $query .=
"s_view_department_tickets='$u_view_department_tickets', ";
      $query .= "s_add_categories='$u_add_categories', ";
      $query .= "s_delete_categories='$u_delete_categories', ";
      $query .= "s_add_departments='$u_add_departments', ";
      $query .= "s_delete_departments='$u_delete_departments', ";
      $query .= "s_manage_users='$u_manage_users', ";
      $query .= "s_add_parts='$u_add_parts', ";
      $query .= "s_manage_clients='$u_manage_clients' "; //my addition
      $query .= "WHERE s_user='$txtUsername';";
      $mysql_result = mysql_query($query, $mysql_link);
As I said. All other settings are being updated, but mine (marked //my addition). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.db (#7013) next »