05-12-2012, 01:56
Witam. Jestem pewien , że skrypt działa w 100%.
Struktura tabeli:
Błąd:
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 'add='Dodał', data=now()' at line 1
Hmm, co jest nie tak?
Kod PHP:
<?PHP
$formularz = '
<form action="?do=add_comment" method="post">
<input type="text" name="add" value="Dodał"><br />
<textarea name="text" cols="65" rows="3">Treść komentarza. Max. 255 znaków.</textarea><br />
<input type="submit" name="submit" value="Dodaj">
</form>
';
$add = addslashes(htmlspecialchars($_POST['add']));
$text = addslashes(htmlspecialchars($_POST['text']));
if(isset($_POST['submit'])) {
$zapytanie = @mysql_query("INSERT INTO comments SET article_id='$id', text='$text', add='$add', data=now()");
echo mysql_error();
echo '<br>Pomyślnie dodano komentarz!';
} else {
echo $formularz; }
?>
Struktura tabeli:
Kod PHP:
CREATE TABLE `comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`article_id` int(11) NOT NULL,
`title` varchar(50) NOT NULL,
`text` text NOT NULL,
`add` varchar(50) NOT NULL,
`data` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
Błąd:
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 'add='Dodał', data=now()' at line 1
Hmm, co jest nie tak?