Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Can't edit certain column [MySQL/phpMyAdmin]

Guest
May 02, 2010 May 02, 2010

Copy link to clipboard

Copied

Hi there,

I got a little problem with my new website. The thing is that I got web page that edits entries in my phpmyAdmin database.

This works with the only exeption that I can not edit the column "uhrzeit", everything else works like a charm. 😉

here is the php-code of that site: (I highlighted where ever the "uhrzeit" column appears)

<?php require_once('../Connections/Ortner_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $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']);
}

$_POST['datum'] = date("Y-m-d", strtotime($_POST['datum'])); 
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE ortner_termine SET datum=%s, was=%s, beschreibung=%s, wo=%s, Uhrzeit=%s WHERE id=%s",
                       GetSQLValueString($_POST['datum'], "date"),
                       GetSQLValueString($_POST['was'], "text"),
                       GetSQLValueString($_POST['beschreibung'], "text"),
                       GetSQLValueString($_POST['wo'], "text"),
                       GetSQLValueString($_POST['uhrzeit'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_Ortner_db, $Ortner_db);
  $Result1 = mysql_query($updateSQL, $Ortner_db) or die(mysql_error());
}

mysql_select_db($database_Ortner_db, $Ortner_db);
$query_termin_auswahl = "SELECT id, datum, was, wo FROM ortner_termine ORDER BY id DESC";
$termin_auswahl = mysql_query($query_termin_auswahl, $Ortner_db) or die(mysql_error());
$row_termin_auswahl = mysql_fetch_assoc($termin_auswahl);
$totalRows_termin_auswahl = mysql_num_rows($termin_auswahl);

$colname_termin_edit = "-1";
if (isset($_GET['Termineintrag'])) {
  $colname_termin_edit = $_GET['Termineintrag'];
}
mysql_select_db($database_Ortner_db, $Ortner_db);
$query_termin_edit = sprintf("SELECT * FROM ortner_termine WHERE id = %s", GetSQLValueString($colname_termin_edit, "int"));
$termin_edit = mysql_query($query_termin_edit, $Ortner_db) or die(mysql_error());
$row_termin_edit = mysql_fetch_assoc($termin_edit);
$totalRows_termin_edit = mysql_num_rows($termin_edit);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Christian Ortner</title>
<meta name="author" content="matthias.damoser@media-powerplant.de"/>
<meta name="copyright" content="Webdesign: Matthias Damoser / media powerplant"/>
<link href="../styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
     <div id="header"><a href="../index.php"><img src="../bilder/header.jpg" width="616" height="109" alt="Christian Ortner Startseite" /></a></div><!-- end of header -->
    <div id="menu">
         <ul>
             <li><a href="../bio.html">Biografie</a></li>
            <li><a href="../musik.html">Musik</a></li>
            <li><a href="../medien.html">Medien</a></li>
            <li><a href="../projekte.html"> Projekte</a></li>
            <li><a href="../termine.php">Termine</a></li>
            <li><a href="../kontakt.html">Kontakt</a></li>
        </ul>
    </div><!-- end of menu -->
  <div class="trenner"></div><!-- end of trenner -->
    <div id="redaktion">
    <h3>Willkommen im Administrationsbereich</h3>
    <p>Hier können Sie bereits bestehende Termine bearbeiten:</p>
    <form id="terminauswahl" name="terminauswahl" method="get" action="date_edit.php">
    Bitte auswählen:
      <select name="Termineintrag" id="Termineintrag" tabindex="10">
        <?php
do { 
?>
        <option value="<?php echo $row_termin_auswahl['id']?>"><?php echo $row_termin_auswahl['was']?> (<?php echo $row_termin_auswahl['datum']?> )</option>
        <?php
} while ($row_termin_auswahl = mysql_fetch_assoc($termin_auswahl));
  $rows = mysql_num_rows($termin_auswahl);
  if($rows > 0) {
      mysql_data_seek($termin_auswahl, 0);
       $row_termin_auswahl = mysql_fetch_assoc($termin_auswahl);
  }
?>
      </select>
      <input type="submit" name="button" id="button" value="auswählen" />
    </form>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
      <table align="center">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Datum:</td>
          <td><input type="text" name="datum" value="<?php echo htmlentities($row_termin_edit['datum'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Art der Veranstaltung:</td>
          <td><input type="text" name="was" value="<?php echo htmlentities($row_termin_edit['was'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">zusätzlich Beschreibung (optional):</td>
          <td><input type="text" name="beschreibung" value="<?php echo htmlentities($row_termin_edit['beschreibung'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Ort der Veranstaltung:</td>
          <td><input type="text" name="wo" value="<?php echo htmlentities($row_termin_edit['wo'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Uhrzeit:</td>
          <td><input type="text" name="Uhrzeit" value="<?php echo htmlentities($row_termin_edit['uhrzeit'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right"> </td>
          <td><input type="submit" value="Datensatz aktualisieren" /></td>
        </tr>
      </table>
      <input type="hidden" name="id" value="<?php echo $row_termin_edit['id']; ?>" />
      <input type="hidden" name="MM_update" value="form1" />
      <input type="hidden" name="id" value="<?php echo $row_termin_edit['id']; ?>" />
    </form>
<p class="backlink"><a href="../redaktionssystem.php">zurück zur Termin Verwaltung</a></p>     
   </div><!-- end of redaktion -->
<div id="rot"></div><!-- end of rot-->
    <div id="fotobereich"></div>
     <p>Copyright © 2010 | Alle Rechte vorbehalten | <a href="impressum.html">Impressum</a> | <a href="kontakt.html">Kontakt</a> | <a href="redaktionssystem_login.php">Log-In</a> |</p>
</div><!-- end of wrapper -->
</body>
</html>
<?php
mysql_free_result($termin_auswahl);

mysql_free_result($termin_edit);
?>

Thank you very much for your help!

TOPICS
Server side applications

Views

927
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

LATEST

I barely understand ur script because it's not fully in English but I guess I could say u are trying to update the ortner_terminate table right?I think for the date u should change like below.

$date = date("Y-m-d", strtotime($_POST['datum'])); 
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE ortner_termine SET datum='$date', was=%s, beschreibung=%s, wo=%s, Uhrzeit=%s WHERE id=%s",
                       GetSQLValueString($_POST['was'], "text"),
                       GetSQLValueString($_POST['beschreibung'], "text"),
                       GetSQLValueString($_POST['wo'], "text"),
                       GetSQLValueString($_POST['uhrzeit'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_Ortner_db, $Ortner_db);
  $Result1 = mysql_query($updateSQL, $Ortner_db) or die(mysql_error());
}

Well, I could say u are trying to display the data on form once u clicked the option from list menu. U have to change the termin_edit recordset by filter it as below.

2010-05-05_1201.png

Not using the URL parameter since u are trying to view the data on the same page.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines