Kimble
Erfahrenes Mitglied
hi,
was ist an folgendem Code falsch?
Ich uebergeb per $_POST die Variablen aber es kommt immer eine Fehlermeldung:
un hier der code:
ich weiss wirklich nicht was an dem SQL syntax falsch ist
Bitte helft!
was ist an folgendem Code falsch?
Ich uebergeb per $_POST die Variablen aber es kommt immer eine Fehlermeldung:
PHP:
Error while updating news: You have an error in your SQL syntax near 'WHERE id=11' at line 1
un hier der code:
ich weiss wirklich nicht was an dem SQL syntax falsch ist
Bitte helft!
PHP:
<?php
$dbcnx = mysql_connect( "localhost", "Jan Fischer", "ibidcset" );
mysql_select_db( "clan" );
if( $send != "save" ) {
$sql = mysql_query("SELECT createdby, email, topic, inhalt, ndate, ntime, comments FROM " .
"cms_news WHERE id=$id");
$sql = mysql_fetch_array( $sql );
?>
<html>
<head>
<title>CMS System</title>
<link rel="stylesheet" type="text/css" href="style/color.css" />
</head>
<body>
<div align="center">
<p><b><u>Edit: <?=$sql['topic']?></u></b></p>
<form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
<table width="500" border="0" cellpadding="3" cellspacing="1">
<tr>
<th width="100" align="left">created by</th>
<td class="view">
<input name="createdby" maxlength="50" size="50" value="<?=$sql['createdby']?>" />
</td>
</tr>
<tr>
<th width="100" align="left">email</th>
<td class="view"><input name="email" maxlength="100" size="50" value="<?=$sql['email']?>" /></td>
</tr>
<tr>
<th width="100" align="left">topic</th>
<td class="view"><input name="topic" maxlength="50" size="50" value="<?=$sql['topic']?>" /></td>
</tr>
<tr>
<th width="100" align="left">content</th>
<td class="view"><textarea rows="5" name="inhalt" cols="50"><?=$sql['inhalt']?></textarea></td>
</tr>
<tr>
<th width="100" align="left">date</th>
<td class="view"><input name="ndate" size="50" value="<?=$sql['ndate']?>" /></td>
</tr>
<tr>
<th width="100" align="left">time</th>
<td class="view"><input name="ntime" size="50" value="<?=$sql['ntime']?>" /></td>
</tr>
<tr>
<th width="100" align="left">comments</th>
<td class="view"><?=$sql['comments']?> - can not be edited
<input type="hidden" size="1" name="id" value="<?=$id?>" /></td>
</tr>
<tr>
<td colspan="2" align="center" class="view">
<input type="submit" name="send" value="save" />
<input type="reset" name="reset" value="reset" />
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
} else {
$sql = "UPDATE cms_news SET createdby='$_POST[createdby]', email='htmlspecialchars($_POST[email])', " .
"topic='$_POST[topic]', inhalt='$_POST[inhalt]', ndate='$_POST[ndate]', " .
"ntime='$_POST[ntime]', WHERE id=$_POST[id]";
mysql_query( $sql ) or die("Error while updating news: " . mysql_error());
header("Location: index.php");
exit();
}
?>
Zuletzt bearbeitet: