Dit is de code:
//Creates the table for pages and messages
$sql = "
CREATE TABLE IF NOT EXISTS `pages` (
`id` int NOT NULL AUTO_INCREMENT primary key,
`title` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
";
$result = mysql_query($sql) or die("creating the table pages failed..");
$sql = "
CREATE TABLE IF NOT EXISTS `messages` (
`id` int AUTO_INCREMENT primary key NOT NULL,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`page` varchar(255) NOT NULL,
`posting_date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
";
$result = mysql_query($sql) or die("creating the table messages failed..");
/********************************************
De query van messages maken werkt niet?
********************************************/
//This creates 2 pages and makes a message on the homepage and on the firstpage page.
$time = time();
$sql = "
INSERT INTO pages (title) VALUES ('Home');
INSERT INTO pages (title) VALUES ('firstpage');
INSERT INTO messages (title, description, page, posting_date) VALUES ('<h1>This is your first Message!</h1>', '<p>You can change this message if you like in the admin panel.</p>', 'home', '$time');
INSERT INTO messages (title, description, page, posting_date) VALUES ('<h1>Welcome to an example page!</h1>', '<p>This is just another test message and you can choose if you want to delete or modify this message in the admin panel.</p>', 'firstpage', '$time');
";
$result = mysql_query($sql) or die("SQL ERROR IN POST MAKING");
Als ik deze code uitvoer krijg ik altijd SQL ERROR IN POST MAKING. Dus in de laatste query zit een fout. Maar ik kan hem maar niet vinden. Als ik dit in PHPmyadmin uitvoer werkt het wel.?