Her er hele update filen, giver det noget ? Den er lidt stor synes jeg.
<?php require_once('Connections/NytMateriel.php'); ?>
<?php
$tabellen = $_POST['Navn'];
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")) {
$datoen = $_POST['Dato'];
$date = substr($datoen,0,2);
$month = substr($datoen,2,2);
$year = substr($datoen,4,4);
$Dato = $year.'-'.$month.'-'.$date;
$updateSQL = sprintf("UPDATE `$tabellen` SET BestilNr=%s, Opstilling=%s, Forfatter=%s, Titel=%s, Tekst=%s, Forlag=%s, Udgivet=%s, Info=%s, Dato=%s, Koebt=%s WHERE id=%s",
GetSQLValueString($_POST['BestilNr'], "text"),
GetSQLValueString($_POST['Opstilling'], "text"),
GetSQLValueString($_POST['Forfatter'], "text"),
GetSQLValueString($_POST['Titel'], "text"),
GetSQLValueString($_POST['Tekst'], "text"),
GetSQLValueString($_POST['Forlag'], "text"),
GetSQLValueString($_POST['Udgivet'], "text"),
GetSQLValueString($_POST['Info'], "text"),
GetSQLValueString($Dato, "date"),
GetSQLValueString($_POST['Koebt'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_NytMateriel, $NytMateriel);
$Result1 = mysql_query($updateSQL, $NytMateriel) or die(mysql_error());
$updateGoTo = "Menuen.html";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
// $tabellen = $_POST['Navn'];
$nr = $_POST['nr'];
mysql_select_db($database_NytMateriel, $NytMateriel);
$query_Opdater = "SELECT * FROM `$tabellen` WHERE BestilNr = '$nr'";
$Opdater = mysql_query($query_Opdater, $NytMateriel) or die(mysql_error());
$row_Opdater = mysql_fetch_assoc($Opdater);
$totalRows_Opdater = mysql_num_rows($Opdater);
$date = $row_Opdater['Dato'];
$year = substr($date, 0, 4);
$month = substr($date, 5, 2);
$day = substr($date, 8, 2);
$Dato = $day.$month.$year;
?>
<!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=iso-8859-1" />
<title>Rette titel</title>
<link href="style/style.css" rel="stylesheet" type="text/css">
</head>
<body><br />
<?php
$year = substr($tabellen, 0, 4);
$month = substr($tabellen, 4, 2);
$day = substr($tabellen, 6, 2);
echo $day ." ". $month ." ". $year . "Tabellen = " . $tabellen;
setLoc('da_DK.ISO_8859-1');
$new_date = strftime("%e. %B %Y", mktime(0, 0, 0, $month, $day, $year));
?>
<center><h3>RET bestillingsnummer i listen: <?php echo $new_date; ?>.</h3></center>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Id:</td>
<td><?php echo $row_Opdater['id']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">BestilNr:</td>
<td><input type="text" name="BestilNr" value="<?php echo htmlentities($row_Opdater['BestilNr'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Opstilling:</td>
<td><input type="text" name="Opstilling" value="<?php echo htmlentities($row_Opdater['Opstilling'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Forfatter:</td>
<td><input type="text" name="Forfatter" value="<?php echo htmlentities($row_Opdater['Forfatter'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Titel:</td>
<td><input type="text" name="Titel" value="<?php echo htmlentities($row_Opdater['Titel'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tekst:</td>
<td><input type="text" name="Tekst" value="<?php echo htmlentities($row_Opdater['Tekst'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Forlag:</td>
<td><input type="text" name="Forlag" value="<?php echo htmlentities($row_Opdater['Forlag'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Udgivet:</td>
<td><input type="text" name="Udgivet" value="<?php echo htmlentities($row_Opdater['Udgivet'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Info:</td>
<td><input type="text" name="Info" value="<?php echo htmlentities($row_Opdater['Info'], ENT_COMPAT, 'iso-8859-1'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Dato:</td>
<td><input type="text" name="Dato" value="<?php echo $Dato; ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Koebt:</td>
<td><input type="radio" name="Koebt" value="Ja" <?php if (!(strcmp(htmlentities($row_Opdater['Koebt'], ENT_COMPAT, 'iso-8859-1'),"ja"))) {echo "CHECKED";} ?> />
Ja <input type="radio" name="Koebt" value="Nej" <?php if (!(strcmp(htmlentities($row_Opdater['Koebt'], ENT_COMPAT, 'iso-8859-1'),"nej"))) {echo "CHECKED";} ?> />
Nej</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value=" Opdatér titlen " /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $row_Opdater['id']; ?>" />
</form>
<br />
<center><a href="Menuen.html" target="_parent">Tilbage til MENU</a></center>
<?php
function setLoc($loc) {
$ii=0;
do {
$locale_result = setlocale(LC_TIME, $loc);
} while ($locale_result != $loc && $ii++ < 10);
}
?>
</body>
</html>
<?php
mysql_free_result($Opdater);
?>
Og laver jeg en fast tabel - altså skriver en af tabellerne istedet for at bruge $tabellen så virker denne også. Når jeg kommer til filen udskrives tabellen og der står det rigtige i. Men når jeg trykker på opdater, så er den tom. Nogen der kan finde en fejl ? Alle andre filer hvor jeg også bruger $tabellen, virker det - det er altså bare underligt, synes jeg.