Update not updating :(

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Update not updating :(

    Hi guys,
    Still having problems with updating my mysql database records.

    I can now enter the data i want to update but, when I check the database
    record its still the same, untouched :(

    Help!!!!!!!!

    <?php require_once('Connections/connect.php'); ?>
    <?
    session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
    // For security, start by assuming the visitor is NOT authorized.
    $isValid = False;

    // When a visitor has logged into this site, the Session variable
    MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that Session variable
    is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users
    based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their
    username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    }
    if (($strUsers == "") && true) {
    $isValid = true;
    }
    }
    return $isValid;
    }

    $MM_restrictGoTo = "index.php";
    if (!((isset($_SESSION['MM_Username'])) &&
    (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'],
    $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" .
    urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    }
    ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
    $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
    "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
    $updateSQL = sprintf("UPDATE menu SET Name=%s, Description=%s, Catergory=%s,
    Price=%s, `View`=%s WHERE MID=%s",
    GetSQLValueString($_POST['Name'], "text"),
    GetSQLValueString($_POST['Description'], "text"),
    GetSQLValueString($_POST['Catergory'], "text"),
    GetSQLValueString($_POST['Price'], "text"),
    GetSQLValueString($_POST['View'], "text"),
    GetSQLValueString($_POST['MID'], "int"));

    mysql_select_db($database_connect, $connect);
    $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());

    $updateGoTo = "cpanel.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $updateGoTo));
    }

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
    $updateSQL = sprintf("UPDATE menu SET Name=%s, Description=%s, Catergory=%s,
    Price=%s, `View`=%s WHERE MID=%s",
    GetSQLValueString($_POST['Name'], "text"),
    GetSQLValueString($_POST['Description'], "text"),
    GetSQLValueString($_POST['Catergory'], "text"),
    GetSQLValueString($_POST['Price'], "text"),
    GetSQLValueString($_POST['View'], "text"),
    GetSQLValueString($_POST['MID'], "int"));

    mysql_select_db($database_connect, $connect);
    $Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());

    $updateGoTo = "cpanel.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $updateGoTo));
    }

    mysql_select_db($database_connect, $connect);
    $query_Recordset1 = "SELECT * FROM menu ORDER BY MID ASC";
    $Recordset1 = mysql_query($query_Recordset1, $connect) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Modify Item</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    .style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-weight: bold;
    font-size: 16px;
    }
    -->
    </style>
    </head>

    <body>
    <table width="691" border="0" align="center">
    <tr>
    <td width="685" valign="top" bgcolor="#0099CC"><table width="200"
    border="0" align="center">
    <tr>
    <td><div align="center" class="style1">Modify Item </div></td>
    </tr>
    </table>
    <table width="656" border="0" align="center">
    <tr>
    <td width="628">&nbsp;</td>
    </tr>
    <tr>
    <td><table width="652" border="0" align="center">
    <?php do { ?>
    <tr>
    <td width="72" bgcolor="#00CCFF">ID:</td>
    <td width="158" valign="top" bgcolor="#00CCFF"><?php echo
    $row_Recordset1['MID']; ?></td>
    <td width="59" valign="top" bgcolor="#00CCFF">Name:</td>
    <td width="313" valign="top" bgcolor="#00CCFF"><?php echo
    $row_Recordset1['Name']; ?></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    </tr>
    <tr>
    <td height="51" bgcolor="#00CCFF">Description:</td>
    <td valign="top" bgcolor="#00CCFF"><?php echo
    $row_Recordset1['Description']; ?></td>
    <td valign="top" bgcolor="#00CCFF">Category:</td>
    <td valign="top" bgcolor="#00CCFF"><?php echo
    $row_Recordset1['Catergory']; ?></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    </tr>
    <tr>
    <td bgcolor="#00CCFF">Price:</td>
    <td valign="top" bgcolor="#00CCFF"><?php echo
    $row_Recordset1['Price']; ?></td>
    <td valign="top" bgcolor="#00CCFF">View:</td>
    <td valign="top" bgcolor="#00CCFF"><?php echo
    $row_Recordset1['View']; ?></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    <td valign="top">&nbsp;</td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
    ?>
    </table></td>
    </tr>
    </table>

    <table width="394" border="0" align="center">
    <tr>
    <td width="388">&nbsp;</td>
    </tr>
    <tr>
    <td><div align="center">


    <form method="POST" name="form2" action="<?php echo
    $editFormAction; ?>">
    <table align="center">
    <tr valign="baseline">
    <td nowrap align="right">MID:</td>
    <td><input type="text" name="MID" value="<?php echo
    $row_Recordset1['MID']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Name:</td>
    <td><input type="text" name="Name" value="<?php echo
    $row_Recordset1['Name']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right" valign="top">Description:</td>
    <td><textarea name="Description" cols="50" rows="5"><?php
    echo $row_Recordset1['Description']; ?></textarea>
    </td>
    </tr>
    <tr valign="baseline">
    <td nowrap align="right">Catergory:</td>
    <td><select name="Catergory">
    <option value="Starters" <?php if (!(strcmp("Starters",
    $row_Recordset1['Catergory']))) {echo "SELECTED";} ?>>Starters</option>
    <option value="Chicken" <?php if (!(strcmp("Chicken",
    $row_Recordset1['Catergory']))) {echo "SELECTED";} ?>>Chicken</option>
    <option value="Lamb" <?php if (!(strcmp("Lamb",
    $row_Recordset1['Catergory']))) {echo "SELECTED";} ?>>Lamb</option>
    <option value="Sea Food" <?php if (!(strcmp("Sea Food",
    $row_Recordset1['Catergory']))) {echo "SELECTED";} ?>>Sea Food</option>
    <option value="Vegetable" <?php if
    (!(strcmp("Vegetable", $row_Recordset1['Catergory']))) {echo "SELECTED";}
    ?>>Vegetable</option>
    <option value="Biryani" <?php if (!(strcmp("Biryani",
    $row_Recordset1['Catergory']))) {echo "SELECTED";
    The_FedEx_Guy Guest

  2. Similar Questions and Discussions

    1. MS Access UPDATE not updating with cfquery
      Three columns will update (GolaCalls, GoalContacts, and GoalAppts). However, the two columns FirstName and LastName remain unchanged even if there...
    2. update query not updating
      Hi I am trying to update via an datagrid only nothing seems to happen how would I diplay what the update query looks like msgbox reponse.write?...
    3. Updating AI Files causes position to 'bounce' when updating in Quark
      Is there any way to build Illustrator files so that no matter what edit you might come back and make to the AI file, when you update the modified...
    4. Updating DataGrid while editing, doesn't update
      I can't seem to get the update piece working properly while doing in-place editing. I don't receive any errors, but the update doesn't take place....
    5. Update Stats not updating for all the Tables
      Hi All We are running Update statistics high for the whole database every night as a cron job, as our database is small of 1.5 GB. When i run...
  3. #2

    Default Re: Update not updating :(


    "The_FedEx_Guy" <webforumsuser@macromedia.com> wrote in message
    news:cvii2h$8pd$1@forums.macromedia.com...
    > Hi guys,
    > Still having problems with updating my mysql database records.
    >
    > I can now enter the data i want to update but, when I check the database
    > record its still the same, untouched :(
    >
    > Help!!!!!!!!
    <snip>

    In reviewing the code, it appears that you have two of the
    same if() statements:

    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {

    Also, try printing out variables to see if they contain
    the expected information.

    HTH

    -Rb

    -Rb Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139