Jump to content

seanoll

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

seanoll's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I have a page to edit records in a database and then go to a "success page". The edit page calls the records fine, you change the data and click update record. It goes to the "success page" but the data has not changed in the database. I hope that someone can point out what I am doing wrong as it is driving me up the wall. Many Thanks The code I am using is: <?php require_once('../Connections/connScheduleEdit.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form1")) { $updateSQL = sprintf("UPDATE schedule_route SET start_date=%s, location=%s, information=%s WHERE 'index'=%s", GetSQLValueString($_POST['start_date'], "text"), GetSQLValueString($_POST['location'], "text"), GetSQLValueString($_POST['information'], "text"), GetSQLValueString($_POST['index'], "int")); mysql_select_db($database_connScheduleEdit, $connScheduleEdit); $Result1 = mysql_query($updateSQL, $connScheduleEdit) or die(mysql_error()); $updateGoTo = "schedule_edit_success.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_connScheduleEdit, $connScheduleEdit); $query_rsSceduleEdit = "SELECT * FROM schedule_route ORDER BY `index` ASC"; $rsSceduleEdit = mysql_query($query_rsSceduleEdit, $connScheduleEdit) or die(mysql_error()); $row_rsSceduleEdit = mysql_fetch_assoc($rsSceduleEdit); $totalRows_rsSceduleEdit = mysql_num_rows($rsSceduleEdit); ?><!--End Schedule Update --> and the form is: <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <?php do { ?> <table align="center"> <tr valign="top"> <td align="right" nowrap>Start Date</td> <td><input type="text" name="start_date" value="<?php echo $row_rsSceduleEdit['start_date']; ?>" size="32"></td> </tr> <tr valign="top"> <td align="right" nowrap>Location</td> <td><textarea name="location" cols="32"><?php echo $row_rsSceduleEdit['location']; ?></textarea></td> </tr> <tr valign="top"> <td align="right" nowrap>Information</td> <td><textarea name="information" cols="32" rows="6"><?php echo $row_rsSceduleEdit['information']; ?></textarea></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Update record"></td> </tr> </table> <p> <input type="hidden" name="id_user" value="<?php echo $row_rsSceduleEdit['index']; ?>"> <input type="hidden" name="MM_update" value="form1"> </p> <?php } while ($row_rsSceduleEdit = mysql_fetch_assoc($rsSceduleEdit)); ?> <p> </p> <p> </p> <p> </p> </form> <?php mysql_free_result($rsSceduleEdit); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.