Hvorfor siger den id findes ikke?
Hej.jeg har følgende kode:
<?php
require "db.php";
?>
<?php
$message = '';
if (isset($_POST['tekst'])) {
$tekst = addslashes($_POST['tekst']);
$id = intval($_POST['id']);
$navn = addslashes($_POST['navn']);
$pris = addslashes($_POST['pris']);
$mpris = addslashes($_POST['mpris']);
$gten = addslashes($_POST['gten']);
$gtto = addslashes($_POST['gtto']);
$gttre = addslashes($_POST['gttre']);
$gtfire = addslashes($_POST['gtfire']);
mysql_query("UPDATE stole SET tekst='$tekst', navn='$navn', pris='$pris', mpris='$mpris', gten='$gten', gtto='$gtto', gttre='$gttre', gtfire='$gtfire' WHERE id='$id'") or die(mysql_error());
$query = mysql_query("SELECT * FROM stole WHERE id='$id'");
$row = mysql_fetch_array($query);
$message = "<div align='center' style='font: smaller Verdana, Geneva, Arial, Helvetica, sans-serif; color: white;'>$row[navn] blev opdagteret.</div>";
}
?>
<?php
if( isset($_GET['id']) ) {
$id = mysql_escape_string($_GET['id']); // sikre id
$sql = "SELECT navn, tekst, pris, gten, gtto, gttre, gtfire, mpris FROM stole WHERE id={$id}";
$res = mysql_query($sql);// or die(mysql_error());
if( $res )
$row = mysql_fetch_array($res);
else
$row = false;
}
else {
$row = false;
}
?>
<?php
//sti til mappen som skal åbnes for læsning. I dette tilfælde den aktuelle mappe
$path = opendir("../rpicstole/");
//filerne skal i et array for at kunne tælles
$billeder = array();
//Vi læser dir igennem for filer
while (false !== ($dir = readdir($path))){
//Laver et array med de filer i mappen som ikke skal vises
$ejvist = array(".", "..", "rand.php", "README.html", "HEADER.shtml", "rand.zip");
//Er filen i arrayet ejvist fortsætter vi
if (in_array($dir, $ejvist)) {
continue;
}else{
//"tilegner" filerne til arrayet billeder vi definerede tidligere
$billeder[] = $dir;
}
}
closedir($path);
//Tæl billeder og brug rand
$vistbillede = rand(0, count($billeder) -1);
?>
<html>
<head>
<title>Domusitalia</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../css/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("cont").getElementsByTagName("DIV");
if(el.style.display == "none"){
for (var i=0; i<ar.length; i++){
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
function ChangeClass(menu, newClass) {
if (document.getElementById) {
document.getElementById(menu).className = newClass;
}
}
document.onselectstart = new Function("return false");
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
Function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onLoad="MM_preloadImages('img/pilon.gif')">
<center>
<table width="0" border="0" height="0" cellpadding="0" cellspacing="5">
<!--DWLayoutTable-->
<tr>
<td width="243" height="0" valign="top"><img src="../img/1.jpg" name="l1" width="243" height="243" id="l1" /></td>
<td width="243" valign="top"><img src="../img/2.jpg" name="l2" width="243" height="243" id="l2" /></td>
<td width="243" valign="top"><img src="../rpicstole/<? echo $billeder[$vistbillede]; ?>" width="243" height="243"></td>
</tr>
<tr>
<td height="106" valign="top"><a href="index2.php" class="menulink">Forside</a> <a href="information.php" class="menulink">Information</a> <a href="besogindex.php" class="menulink">Besøgende</a><br>
<font size="2" color="#FFFFFF"><b><font size="3"> </font></b></font>
<table width="246" height="30" border="0" cellpadding="0" cellspacing="0">
<tr>
<td background="../img/streg.jpg"><font size="2" color="#FFFFFF"><b><font size="3"> Rediger tekst i: </font></b></font></td>
</tr>
</table>
<font size="2" color="#FFFFFF"><b></b></font>
<div id="cont">
<p id="menu1" class="menuOut" onclick="SwitchMenu('sub1')" onmouseover="ChangeClass('menu1','menuOver')" onmouseout="ChangeClass('menu1','menuOut')"><a href="http://www.venetacucine.it/catalogo/default_eng.htm" target="_blank">Køkken</a></p>
<p id="menu2" class="menuOut" onclick="SwitchMenu('sub2')" onmouseover="ChangeClass('menu2','menuOver')" onmouseout="ChangeClass('menu2','menuOut')">Bad</p>
<div class="menulink" id="sub2" style="display:none;"> <a class="menulink" href="#" title="Kommer snart">Kommer snart</a><br/>
<a class="menulink" href="#" title="Kommer snart">Kommer snart</a><br/>
</div>
<p id="menu3" class="menuOut" onclick="SwitchMenu('sub3')" onmouseover="ChangeClass('menu3','menuOver')" onmouseout="ChangeClass('menu3','menuOut')"><a href="stole.php">Stole</a></p>
<p id="menu4" class="menuOut" onclick="SwitchMenu('sub4')" onmouseover="ChangeClass('menu4','menuOver')" onmouseout="ChangeClass('menu4','menuOut')"><a href="rumdel.php?id=1">Rumdeler</a></p>
<p id="menu4" class="menuOut" onclick="SwitchMenu('sub5')" onmouseover="ChangeClass('menu4','menuOver')" onmouseout="ChangeClass('menu4','menuOut')">Display</p>
<div class="menulink" id="sub5" style="display:none;"> <a class="menulink" href="display1.php?id=1" title="Display 1">Display 1</a><br/>
<a class="menulink" href="display2.php?id=2" title="Display 2">Display 2</a><br/>
</div>
</div></td>
<td colspan="2" valign="top">
<p class="titel"> Redigering af
<?=$row[navn]?>
</p>
<form action="<? $PHP_SELF ?>" method="post">
<center><?=$message?></center>
<div align="center"></div>
<div align="center"><br>
<?php if( $row ) { ?>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<br>
<table width="270" border="0" cellpadding="0" cellspacing="0" height="170" class="tekst_normal">
<tr class="info" background="../img/info2.jpg">
<td height="18" colspan="2"> <span class="info"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <span class="style1">Tekst i
<?=$row[navn]?>
:</span></font></span></td>
</tr>
<tr>
<td width="116" height="19"><span class="style1">Navn:</span></td>
<td width="154"><div align="center">
<input name="navn" type="text" class="box" id="navn" value="<?php echo $row['navn']; ?>" size="19">
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">eksl moms:</span></td>
<td><div align="center">
<input name="pris" type="text" class="box" id="pris" value="<?php echo $row['prisone']; ?>" size="19">
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">Pris inkl moms:</span></td>
<td><div align="center">
<input name="mpris" type="text" class="box" id="mpris" value="<?php echo $row['mprisone']; ?>" size="19">
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">Tekst: </span></td>
<td><div align="center">
<textarea name="tekst" rows="5" cols="19" class="box"><?php echo $row['tekst']; ?></textarea>
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">Grid tekst 1: </span></td>
<td><div align="center">
<textarea name="gten" cols="19" rows="5" class="box" id="gten"><?php echo $row['gten']; ?></textarea>
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">
<?php if (!empty($row['gtto'])) { ?>
Grid tekst 2: </span></td>
<td><div align="center">
<textarea name="gtto" cols="19" rows="5" class="box" id="gtto"><?php echo $row['gtto']; ?></textarea>
<?php } ?>
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">
<?php if (!empty($row['gttre'])) { ?>
Grid tekst 3: </span></td>
<td><div align="center">
<textarea name="gttre" cols="19" rows="5" class="box" id="gttre"><?php echo $row['gttre']; ?></textarea>
<?php } ?>
</div></td>
</tr>
<tr>
<td height="19"><span class="style1">
<?php if (!empty($row['gtfire'])) { ?>
Grid tekst 4: </span></td>
<td><div align="center">
<textarea name="gtfire" cols="19" rows="5" class="box" id="gtfire"><?php echo $row['gtfire']; ?></textarea>
<?php } ?>
</div></td>
</tr>
</table>
<input type="submit" value="Gem Ændringer" class="submit">
</div>
</form>
<?php } else { ?>
<!-- dette bliver skrevet ud, hvis rækken ikke findes, eller ID ikke er angivet -->
<table width="451" height="8" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26"><center class="style1"> Id'et findes ikke</center></td>
</tr>
</table>
<?php } ?>
<br>
<?
mysql_close();
?></td>
</tr>
<tr>
<td height="0" colspan="3" valign="top" class=footer> Copyright © 2004~2005 by Trevi Aps | Domusitalia</td>
</tr>
</table>
</center>
</body>
</html>
HVORFOR siger den id findes ikke.. Det har sku lige virket for ikke ret lang tid siden ?? Den viser intet.. kun det med id ikke findes.. den skulle meget gerne vise det andet.. og der er sku noget som hedder det id!