php mysql error
hej eksperten jeg får denne fejlSQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id`='2'' at line 1:
her er min kode kan i finde fejlen og rette det
<?
$id = $db->EscapeString($_GET['edit']);
$edit = $db->FetchArray($db->Query("SELECT * FROM `news` WHERE `id`='".$id."'"));
$del = $db->EscapeString($_GET['del']);
$del = $db->FetchArray($db->Query("SELECT id FROM `news` WHERE `id`='".$del."'"));
if($del['id'] != ""){$db->Query("DELETE FROM `news` WHERE `id`='".$del['id']."'");}
$mesaj = '';
if(isset($_POST['submit'])){
$db->Query("UPDATE `users` SET `postedby`='{$_POST['postedby']}', `subject`='{$_POST['subject']}',`date`='{$_POST['date']}', WHERE `id`='{$id}'");
$mesaj = "<div class=\"message success\"><h3>Success!</h3><p>User successfuly edited!</p></div>";
}
$users = $db->GetNumRows($db->Query("SELECT id FROM `users`"));
$active = $db->GetNumRows($db->Query("SELECT id FROM `users` WHERE `banned`='0'"));
$banned = $db->GetNumRows($db->Query("SELECT id FROM `users` WHERE `banned`='1'"));
?>
<body>
<div id="wrapper">
<header id="page-header">
<div class="wrapper">
<div id="util-nav">
</div>
<h1>Admin Panel</h1>
<nav id="main-nav">
<ul class="clearfix">
<li><a href="index.php">Dashboard</a></li>
<li><a href="index.php?x=requests">Requests</a></li>
<li><a href="index.php?x=users">Members</a></li>
<li><a href="index.php?x=settings">Settings</a></li>
<li class="active"><a href="index.php?x=news">news</a></li>
<li id="quick-links" class="fr">
<li id="upgrade" class="fr"><a href="logout.php">Log Out</a></li>
</li>
</ul>
</nav>
</div>
<div id="page-subheader">
<div class="wrapper clearfix">
<nav id="sub-nav">
<ul>
<li><a href="index.php?x=news">Add news</a></li>
<li class="active"><a href="index.php?x=news-new">Delete and edit news</a></li>
</ul>
</nav>
</div>
</div>
</header>
<section id="content">
<div class="wrapper">
<section class="grid_6 first top">
<div class="columns leading">
<div class="grid_6 first"><? if($edit['subject'] != ""){ echo $mesaj;?>
<form id="form" method="post" class="form widget">
<header><h2>Edit User</h2></header>
<section>
<fieldset>
<dl>
<dt></dt><dd><label>postedby</label><input type="text" name="postedby" value="<? echo $edit['postedby']?>" required="required" /></dd>
<dt></dt><dd><label>Subject</label><input type="Text" name="subject" value="<? echo $edit['subject']?>" required="required" /></dd>
<dt></dt><dd><label>News</label><textarea name="news"><? echo $edit['news']; ?></textarea><br /></dd>
</dl>
</fieldset>
<hr />
<button class="button button-green" type="submit" name="submit">Submit</button>
<button class="button button-gray" type="reset">Reset</button>
</section>
</form><?}else{?>
<table class="datatable sortable selectable paginate full">
<thead>
<tr>
<th width="25">ID</th>
<th>subject</th>
<!-- <th>Email</th> -->
<th>Actions</th>
</tr>
</thead>
<tfoot>
<tr>
<th width="25">ID</th>
<th>subject</th>
<!-- <th>Email</th> -->
<th>Actions</th>
</tr>
</tfoot>
<tbody>
<?
$sql = $db->Query("SELECT * FROM `news` ORDER BY `id` ASC");
$num = $db->GetNumRows($sql);
for($j=1; $new = $db->FetchArray($sql); $j++)
{
?>
<tr>
<td><?=$new['id']?></td>
<td><?=$new['subject']?></td>
<!-- <td><?=$user['email']?></td> -->
<td><ul class="action-buttons">
<li><a href="index.php?x=news-new&edit=<?=$new['id']?>" class="action-button" title="Edit User"><span class="user-edit"></span></a></li>
<li><a href="index.php?x=news-new&del=<?=$new['id']?>" class="action-button" title="Delete User"><span class="user-delete"></span></a></li></ul></td>
</tr>
<?}?>
</tbody>
</table><?}?>
</div>
</div>
<div class="clear"> </div>
</section>
<aside class="grid_2 top">
<div class="accordion">
<header class="current"><h2>Users</h2></header>
<section style="display:block">
<dl>
<dt>Paid Users (<?=$active?>)</dt>
<dd><div class="progress progress-green"><span style="width: <?= @percent($active, $users);?>%;"><b><? echo @percent($active, $users);?>%</b></span></div></dd>
<dt>Unpaid Users (<?=$banned?>)</dt>
<dd><div class="progress progress-red"><span style="width: <?= @percent($banned, $users);?>%;"><b><? echo @percent($banned, $users);?>%</b></span></div></dd>
</dl>
</section>
</div>
</aside>
<div class="clear"></div>
</div>
<div id="push"></div>
</section>
</div>
<footer id="page-footer">
<div id="footer-inner">
<p class="wrapper">All rights reserved © <?=date('Y')?> <a href="http://mn-shop.net" target="_blank">MafiaNet</a></p>
</div>
</footer>
</body>
og lige en anden ting som i kan se på koden nedunder skal den tilføje dato til mysql databasen men den tilføjer ikke den rigtig dato den tilføjer 31-12-1969 kan i finde fejlen
<?
if(isset($_POST['submit'])){
$db->Query("INSERT INTO `news` (postedby , news , subject , date) VALUES('{$_POST['postedby']}', '{$_POST['news']}', '{$_POST['subject']}', '{$_POST['date']}')");
$mesaj = "<div class=\"message success\"><h3>Success!</h3><p>User successfuly added!</p></div>";
}
$users = $db->GetNumRows($db->Query("SELECT id FROM `users`"));
$active = $db->GetNumRows($db->Query("SELECT id FROM `users` WHERE `banned`='0'"));
$banned = $db->GetNumRows($db->Query("SELECT id FROM `users` WHERE `banned`='1'"));
?>
<body>
<div id="wrapper">
<header id="page-header">
<div class="wrapper">
<div id="util-nav">
</div>
<h1>Admin Panel</h1>
<nav id="main-nav">
<ul class="clearfix">
<li><a href="index.php">Dashboard</a></li>
<li><a href="index.php?x=requests">Requests</a></li>
<li><a href="index.php?x=users">Members</a></li>
<li><a href="index.php?x=settings">Settings</a></li>
<li class="active"><a href="index.php?x=news">news</a></li>
<li id="quick-links" class="fr">
<li id="upgrade" class="fr"><a href="logout.php">Log Out</a></li>
</li>
</ul>
</nav>
</div>
<div id="page-subheader">
<div class="wrapper clearfix">
<nav id="sub-nav">
<ul>
<li class="active"><a href="index.php?x=news">Add news</a></li>
<li><a href="index.php?x=news-new">Delete and edit news</a></li>
</ul>
</nav>
</div>
</div>
</header>
<section id="content">
<div class="wrapper">
<section class="grid_6 first top">
<div class="columns leading">
<div class="grid_6 first"><? echo $mesaj;?>
<form id="form" method="post" class="form widget">
<header><h2>Add news</h2></header>
<section>
<fieldset>
<dl>
<dt></dt><dd><label>Posted By</label><input type="text" name="postedby" value="" required="required" /></dd>
<dt></dt><dd><label>subject</label><input type="text" name="subject" value="" required="required" /></dd>
<dt></dt><dd><label>News</label><textarea name="news"></textarea><br /></dd>
</dl>
</fieldset>
<hr />
<button class="button button-green" type="submit" name="submit">Submit</button>
<button class="button button-gray" type="reset">Reset</button>
</section>
</form>
</div>
</div>
<div class="clear"> </div>
</section>
<aside class="grid_2 top">
<div class="accordion">
<header class="current"><h2>Users</h2></header>
<section style="display:block">
<dl>
<dt>Paid Users (<?=$active?>)</dt>
<dd><div class="progress progress-green"><span style="width: <?= @percent($active, $users);?>%;"><b><? echo @percent($active, $users);?>%</b></span></div></dd>
<dt>Unpaid Users (<?=$banned?>)</dt>
<dd><div class="progress progress-red"><span style="width: <?= @percent($banned, $users);?>%;"><b><? echo @percent($banned, $users);?>%</b></span></div></dd>
</dl>
</section>
</div>
</aside>
<div class="clear"></div>
</div>
<div id="push"></div>
</section>
</div>
<footer id="page-footer">
<div id="footer-inner">
<p class="wrapper">All rights reserved © <?=date('Y')?> <a href="http://mn-shop.net" target="_blank">MafiaNet</a></p>
</div>
</footer>
</body>
håber nogen kan hjælpe har rudet med det i et par dage nu
er ikke god til php og mysql