Ask a Question related to Dreamweaver AppDev, Design and Development.
-
The_FedEx_Guy #1
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"> </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> </td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top"> </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> </td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top"> </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> </td>
<td valign="top"> </td>
<td valign="top"> </td>
<td valign="top"> </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"> </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
-
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... -
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?... -
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... -
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.... -
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... -
-Rb #2
Re: Update not updating :(
"The_FedEx_Guy" <webforumsuser@macromedia.com> wrote in message
news:cvii2h$8pd$1@forums.macromedia.com...<snip>> 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!!!!!!!!
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



Reply With Quote

