<?php
if($_GET['do'] == "create") {
$newstext = $_POST["news-text"];
$newsheader = $_POST["news-header"];
$date = time();
if($newstext != "" || $newsheader != "") {
include('./inc/mysql_connect.php');
$query1 = "UPDATE news set active = '0'";
$query = "INSERT INTO news (id, news-text, news-header, news-user, news_time, active) VALUES('', '".$newstext."', '".$newsheader."', '".$_SESSION['username']."', '".$date."', '1')";
mysql_query($query1) or die ("Error in query: $query1. ".mysql_error());;
mysql_query($query) or die ("Error in query: $query. ".mysql_error());;
echo "<br />News added!";
}else{
echo "<br />News-text or news-header is blank!";
}
}else{
?>
<form name="news" action="admin-news.php?do=create" method="POST">
<font color="black" face="Georgia" size="5">
<input type="text" style="font-family:Georgia;background-color : #000000;color : #666666;border : 1px solid darkgray;" size="30" name="news-header" value="Write news header here"><br /><br />
<textarea id="textarea1" name="news-text" style="width:500px;height:250px;">
Write news text here!
</textarea><br />
</font>
<input type='submit' value='Post news!' name='submit'>
</form>
<?php
}
?>
Udløser fejlen:
Error in query: INSERT INTO news (id, news-text, news-header, news-user, news_time, active) VALUES('', '<div style="text-align: center;">If you see this news it means that news system works!<br>Website is made by silver and everything coded by him!<br></div>', 'Works!', 'SILVER', '1608809077', '1'). 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 '-text, news-header, news-user, news_time, active) VALUES('', '<div style="" at="" line="" 1=""></div>
Jeg har bare ikke nogen ide om hvad det kan være. Måske kan det være fordi jeg har et javascript på til at lave extarea om så den automatisk laver al html coden(Fra når man skifter linje, om man vil ha texten i mitten eller...)
Indlæg senest redigeret d. 24.12.2009 12:29 af Bruger #14614