I am busy with an news script that is working with an log-in.
I was busy with an edit script to edit the posted news but now I get an Mysql error and I can’t correct it, so I hope someone here can help me.
Owyeah and you can go to the first page to edit then fill in everything but wen you push the submit button you get the error.
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 ‘( id ) = ”’ at line 1
Page editnews.php (is included)
[code=php]<?php
include(“config.php”);
include(“flood.php”);
if ($MySession->Loggedin == 1)
{
//===========================================================//
$Query2 = mysql_query(“SELECT * FROM `news` WHERE id=’$newsid'”);
$news2 = mysql_fetch_object($Query2);
$Result = mysql_num_rows($Query2);
$Query9 = mysql_query(“SELECT * FROM `members` WHERE USERNAME=’$MySession->Username'”);
$Member9 = mysql_fetch_object($Query9);
$Query13 = mysql_query(“SELECT * FROM `profiles` WHERE id=’$Member9->id'”);
$Profile13 = mysql_fetch_object($Query13);
$Query9 = mysql_query(“SELECT * FROM `members` WHERE USERNAME=’$news->AUTHOR'”);
$Member9 = mysql_fetch_object($Query9);
//===========================================================//
if ($Profile13->RANK == “Administrator” OR $Profile13->RANK == “Moderator” OR $news2->AUTHOR == “$MySession->Username”)
{
$author=”$news2->AUTHOR”;
$idnews=”$news2->id”;
$category2=”news2->CATEGORY”;
//===========================================================//
if ($_POST[‘Submit’])
{ //als er op submit is gedrukt gaan we checken of alle velden wel zijn ingevuld …
if ($_POST[‘message’] == “”)
$error = “You have to fill in a message!<br><br>”;
if ($_POST[‘subject’] == “”)
$error = “You have to fill in a titel for you message!<br><br>”;
if (!$error)
{ //als er geen error is
if(!floodfilter(1)) {
echo “You have just posted an message, you must wait 20 seconds before you can post again.<br>
<a href=”javascript:history.go(-1)”>go back.</a>n”;
} else { //als het geen spammen is
//$query =”UPDATE news (AUTHOR, POSTDATE, MAINTEXT,
//SUBJECT, IPADRESS, CATEGORY) VALUES (‘$author’, NOW(), ‘$message’,
//’$subject’, ‘$REMOTE_ADDR’, ‘$category’)”;
$query = “UPDATE news SET AUTHOR=’$author’, SUBJECT=’$subject’, MAINTECT=’$message’, CATEGORY=’$category’ WHERE CONCAT ( id ) = ‘$news2->id'”;
mysql_query($query) or die (mysql_error());
echo “The news item has been updated!!<br>
Look for all the news (and your item) <a href=”index.php”>Here</a><br><br>”;
//als je de comment hebt gepost stuur je de bezoeker terug naar het nieuwsbericht
floodfilter(2); // poster toevoegen aan de floodfilter table
}
}
elseif ($error)
{ //als er een error is
echo ”
<div align=”center”><table width=”50%” border=”1″
cellspacing=”0″ cellpadding=”2″>
<tr bordercolor=”#000000″>
<td bordercolor=”#000000″ bgcolor=”#e2e2e2″ height=”36″>
$error<br>
<form method=”post” action=”javascript:history.go(-1)”>
<input type=”submit” name=”Terug” value=”Terug”>
</form>
</td></tr></table></div>”;
}
}
else
{
?>
<form name=”form” method=”post” action=”index.php”>
<input name=”id” type=”hidden” value=”editnews”>
<table width=”100%” border=”0″><tr>
<td height=”38″>
<strong>Edit news item</strong><br> <td></td></tr>
<td width=”20%”><strong>Author:</strong></td>
<td><? echo $author ; ?></td>
</tr>
<tr>
<td><strong>Category:</strong></td>
<td><select size=”1″ name=”category”>
<option value=”1″<? if ($category2==”1″) { echo” selected”; } ?>>General news</option>
<option value=”2″<? if ($category2==”2″) { echo” selected”; } ?>>Network news</option>
<option value=”3″<? if ($category2==”3″) { echo” selected”; } ?>>Call of Duty news</option>
<option value=”4″<? if ($category2==”4″) { echo” selected”; } ?>>Medal of Honor news</option>
<option value=”5″<? if ($category2==”5″) { echo” selected”; } ?>>Pacific Assault news</option>
</select></td>
</tr>
<tr>
<td><strong>Titel:</strong></td>
<td><input name=”subject” type=”text” size=”50″ maxlength=”30″ value=”<? echo $news2->SUBJECT ; ?>”></td>
</tr>
<tr>
<td valign=”top”><strong>BB codes:</strong></td>
<td>
<? echo “<input type=”button” value=”B” style=”font-weight:bold; width: 30px” onClick=”javascript:addtext(‘message’,'[b]text[/b]’)”>
<input type=”button” value=”i” style=”font-style:italic; width: 30px” onClick=”javascript:addtext(‘message’,'[i]text[/i]’)”>
<input type=”button” value=”u” style=”text-decoration: underline; width: 30px” onClick=”javascript:addtext(‘message’,'[u]text[/u]’)”>
<input type=”button” value=”Lijst” style=”width: 40px” onClick=”javascript:addtext(‘message’,'[list]text[/list]’)”>
<input type=”button” value=”Quote” style=”width: 50px” onClick=”javascript:addtext(‘message’,'[quote]text[/quote]’)”>
<input type=”button” value=”Link” onClick=”javascript:addtext(‘message’,'[url=www.mywebpage.com]My Web Page[/url]’)”>
<input type=”button” value=”Figuur” onClick=”javascript:addtext(‘message’,'[img]www.image.jpg[/img]’)”>
<input type=”button” value=”Code” style=”width: 40px” onClick=”javascript:addtext(‘message’,'[code]text
‘)”><br>”; ?>
</td>
</tr>
<tr>
<td valign=”top”><strong>Smilies:</strong></td>
<td>
<a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/smile.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/biggrin.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’:blink:’)”><img src=”images/smilies/blink.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’-_-‘)”><img src=”images/smilies/closedeyes.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/cool.gif” border=”0″></a><a href=”javascript:addtext(‘message’,'<
<a href=”javascript:addtext(‘message’,’^_^‘)”><img src=”images/smilies/happy.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’:lol:’)”><img src=”images/smilies/laugh.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’:huh:’)”><img src=”images/smilies/huh.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’>
<a href=”javascript:addtext(‘message’,’:mellow:’)”><img src=”images/smilies/mellow.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’:ninja:’)”><img src=”images/smilies/ninja.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/ohmy.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/sad.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/tongue.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’:unsure:’)”><img src=”images/smilies/unsure.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’?’)”><img src=”images/smilies/wink.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’:wub:’)”><img src=”images/smilies/wub.gif” border=”0″></a>
<a href=”javascript:addtext(‘message’,’:wacko:’)”><img src=”images/smilies/wacko.gif” border=”0″></a><a href=”javascript:addtext(‘message’,’:rolleyes:’)”><img src=”images/smilies/rolleyes.gif” border=”0″></a>
</td>
</tr>
<tr><td>
<strong>Message:</strong>
</td>
<td>
<textarea name=”message” cols=”60″ rows=”8″><? echo $news2->MAINTEXT ; ?></textarea>
</td></tr>
<tr><td>
</td><td><div align=”left”>
<input type=”submit” name=”Submit” value=”Edit news”>
<input type=”reset” name=”Reset” value=”Reset fields”>
<input type=”button” value=”Back to news”
onClick=”window.location=’index.php’ ” name=”button”>
</div></td></td></tr></table>
</form>
<?php
}
}
elseif ($Profile13->RANK != “Administrator” OR $Profile13->RANK != “Moderator” OR $news->AUTHOR != “$MySession->Username”)
{
echo”You are not allowed to edit this News Items! Only admins and the poster of the news can.<br><br>”;
echo”Click <a href=”index.php”>Here</a> to go back to the index of World War Shooter Source.”;
}
}
if ($MySession->Loggedin != 1)
{
$REASON=”to post news”
?><form method=”post” action=”index.php”>
<input type=”hidden” name=”Submit” value=”1″><input type=”hidden” name=”sent” value=”27″><input name=”id” type=”hidden” value=”login”>
You don’t have the permission <? echo $REASON ; ?>. You have to be a member of the <b>World War Shooter Source</b> crew to come in this area.<br>
You aren’t logged in yet, so please log-in down here or register at the register page.
Haven’t got an account yet? <a href=”index.php?id=register”>Register here!</a><br>
<br>
<table width=”34%” border=”0″>
<tr>
<td width=”34%”>Username:</td>
<td width=”66%”><input type=”text” name=”LoginName”></td>
</tr>
<tr>
<td>Password:</td>
<td><input type=”password” name=”LoginPassword”></td>
</tr>
<tr>
<td height=”28″> </td>
<td><input name=”submit” type=”submit” value=”Login”> <a href=”index.php?id=register”>Register</a></td>
</tr>
</table>
</form>
<? } ?>[/code]
Mysql table:
CREATE TABLE `news
`id
`SUBJECT
`AUTHOR
`MAINTEXT
`POSTDATE
`IPADRESS
`CATEGORY
PRIMARY KEY (`id
UNIQUE KEY `SUBJECT`SUBJECT
) TYPE=MyISAM COMMENT=’All the news items are listed here.’
AUTO_INCREMENT=7 ;
I hope someone can help me
Thank you ?