skapar först tabellen :
$sql = 'CREATE TABLE `news` (
`id` INT(10) DEFAULT 0 NOT NULL AUTO_INCREMENT,
`headline` VARCHAR( 50 ) NOT NULL,
`preamble` VARCHAR( 50 ) NOT NULL,
`text` TEXT,
`publishingdate` DATETIME NOT NULL,
`author` VARCHAR(50),
PRIMARY KEY ( `id` )
)';
echo 'Creating table: \'news\'....<br><br>';
Blir sedan fel när jag ska lägga in data i news. Så här ser koden ut
$headline = "Overskrift";
$preamble ="Ingress";
$text ="brodtext";
$publishingdate = "2003-03-31 00:00:00";
$author = "jag";
$sql = "INSERT INTO(headline, preamble, text, publishingdate, author) VALUES('$headline', '$preamble', '$text', $publishingdate), '$author')";
print $sql . "<BR><BR>";
mysql_select_db("news", $cn);
mysql_query($sql, $cn ) or die(mysql_error());
felmeddelande:
INSERT INTO(headline, preamble, text, publishingdate, author) VALUES('Overskrift', 'Ingress', 'brodtext', NOW(), 'jag')
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 '(headline, preamble, text, publishingdate, author) VALUES('Over