Jeg prøver å legge inn poster i en tabell ved hjelp av et phpscript, men
får denne feilmeldingen:
"Column count doesn't match value count at row 1"
------------------------------
Slik ser tabellen ut:
Field Type Null Key Default Extra
news_id int(11) PRI NULL auto_increment
heading varchar(48)
body text
date date 0000-00-00
author_name varchar(48)
author_email varchar(48)
------------------------------
Slik ser scriptet ut:
------------------------------
<html>
<head>
<title>Putter data inn i databasen "News"</title>
</head>
<body bgcolor="#FFFFFF">
<?
if(isset($submit)):
$db = mysql_connect ('localhost', 'janvidar')or die(mysql_error
());
mysql_select_db ('TRENING')or die(mysql_error());
$date = date('Y-m-d');
$sql ="INSERT INTO news(news_id, heading, body, date, author,
author_name, author_email)
VALUES(NULL, '$heading', '$body', '$date', '$auth',
'$auth_email')";
mysql_query($sql)or die(mysql_error());;
print("<h2>Dataene er lagt inn</h2>\n");
print("<b>Du kan legge til enda en nyhet under</b><hr>\n");
endif;
?>
<p><h3>Legg inn nyheter i databasen</h3>
<form action="data_in.php3" method="post">
Navn: <input type="text" name="auth"><p>
Email: <input type="text" name="auth_email"><p>
Heading: <input type="text" name="heading"><p>
Innhold:<br>
<textarea cols="40" rows="20" name="body" wrap="virtual">
</textarea><p>
<input type="submit" name="submit" value="Submit news!">
</form>
</body>
</html>
---------------------------------------
Jeg har prøvd med $_POST['$var'], men det fungerte ikke her.
--
mvh Jan Vidar
www.janvidar.com