fejl ved update i MySQL
HejJeg vil opdatere min tabel, men kan ikke få siden til at virke.. er der nogen der kan se hvorfor???
Her er koden:
<?php require_once('../Connections/db.php'); ?>
<?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 = "../ikkeadgang.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"] == "form1")) {
$updateSQL = sprintf("UPDATE spiller SET Navn=%s, Alder=%s, Nationalitet=%s, Klub=%s, idposition=%s, idside=%s WHERE ID=%s",
GetSQLValueString($_POST['Navn'], "text"),
GetSQLValueString($_POST['Alder'], "int"),
GetSQLValueString($_POST['Nationalitet'], "text"),
GetSQLValueString($_POST['Klub'], "text"),
GetSQLValueString($_POST['idposition'], "text"),
GetSQLValueString($_POST['idside'], "text"),
GetSQLValueString($_POST['ID'], "int"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($updateSQL, $db) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_db, $db);
$query_spiller = "SELECT * FROM spiller ORDER BY oprettelse DESC";
$spiller = mysql_query($query_spiller, $db) or die(mysql_error());
$row_spiller = mysql_fetch_assoc($spiller);
$totalRows_spiller = mysql_num_rows($spiller);
mysql_select_db($database_db, $db);
$query_pos = "SELECT * FROM positiontabel ORDER BY positionid ASC";
$pos = mysql_query($query_pos, $db) or die(mysql_error());
$row_pos = mysql_fetch_assoc($pos);
$totalRows_pos = mysql_num_rows($pos);
mysql_select_db($database_db, $db);
$query_sideid = "SELECT * FROM sidetabel ORDER BY SideID ASC";
$sideid = mysql_query($query_sideid, $db) or die(mysql_error());
$row_sideid = mysql_fetch_assoc($sideid);
$totalRows_sideid = mysql_num_rows($sideid);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Ret Spiller</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center">Ret Spiller</p>
<p> </p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Navn:</td>
<td><input type="text" name="Navn" value="<?php echo $row_spiller['Navn']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Alder:</td>
<td><input type="text" name="Alder" value="<?php echo $row_spiller['Alder']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nationalitet:</td>
<td><input type="text" name="Nationalitet" value="<?php echo $row_spiller['Nationalitet']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Klub:</td>
<td><input type="text" name="Klub" value="<?php echo $row_spiller['Klub']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Position:</td>
<td>
<select name="idposition">
<?php
do {
?>
<option value="<?php echo $row_pos['positionnavn']?>" <?php if (!(strcmp($row_pos['positionnavn'], "$row_spiller[\'idposition\']"))) {echo "SELECTED";} ?>><?php echo $row_pos['positionnavn']?></option>
<?php
} while ($row_pos = mysql_fetch_assoc($pos));
?>
</select>
</td>
<tr>
<tr valign="baseline">
<td nowrap align="right">Side:</td>
<td>
<select name="idside">
<?php
do {
?>
<option value="<?php echo $row_sideid['Sidenavn']?>"<?php if (!(strcmp($row_sideid['Sidenavn'], "$row_spiller[\'idside\']"))) {echo "SELECTED";} ?>><?php echo $row_sideid['Sidenavn']?></option>
<?php
} while ($row_sideid = mysql_fetch_assoc($sideid));
$rows = mysql_num_rows($sideid);
if($rows > 0) {
mysql_data_seek($sideid, 0);
$row_sideid = mysql_fetch_assoc($sideid);
}
?>
</select>
</td>
<tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="ID" value="<?php echo $row_spiller['ID']; ?>">
</form>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($spiller);
mysql_free_result($pos);
mysql_free_result($sideid);
?>
Men når jeg gå ind på siden kommer denne fejl:
Parse error: parse error, unexpected T_BAD_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /web/www/frac/users/cmforlife/admin/spillerret.php on line 151
Håber der er nogen der kan hjælpe....
