Jump to content

What's wrong in my script?


Anders Moen

Recommended Posts

Are there anyone who can tell me what the **** is wrong with my script? I've asked on several forums, and no one can seem to figure it out :S

<?php if($_POST['submit']) { $mysql_host = "localhost";$mysql_user = "username";$mysql_pass = "password";$mysql_db = "db_name";$mysql_tabell = "table_name"; $mysql_link = mysql_connect ($mysql_host, $mysql_user, $mysql_pass) or die ("ERROR!"); mysql_select_db ($mysql_db) or die ("ERROR!"); $tittel = htmlspecialchars(strip_tags($_POST['tittel']));$forste = htmlspecialchars(strip_tags($_POST['forste']));$innhold = htmlspecialchars(strip_tags($_POST['innhold']));$navn = htmlspecialchars(strip_tags($_POST['navn']));$epost = htmlspecialchars(strip_tags($_POST['epost']));$ip = $_SERVER['REMOTE_ADDR'];$dato = date("d, m, Y");$mysql_query = "INSERT INTO $mysql_tabell (tittel, forste, innhold, navn, epost, ip, dato) VALUES ('$tittel', '$forste', '$innhold', '$navn', '$epost' '$ip', '$dato')";mysql_query($mysql_query) or die(mysql_error());} else { echo("<form action='' method='post'> <p>Tittel<br /><input type='text' size='80' name='tittel' /></p><p>Første avsnitt<br /><textarea rows='7' cols='60' name='forste'></textarea></p> <p>Resten<br /><textarea rows='7' cols='60' name='innhold'></textarea></p><p>Navn<br /><input type='text' size='80' name='navn' /></p><p>Epost<br /><input type='text' size='80' name='epost' /></p><p><input type='submit' value='Legg til' name='submit' /></p> </form><br /><br />"); }?>

Here's the error message I get when I click submit:"Column count doesn't match value count at row 1"

Link to comment
Share on other sites

On a Dutch forum I read something about this.. if you have a database with columns at this order:IdNameWebsiteYou must insert it also at this order like:NameWebsiteAnd not likeWebsiteNameI don't know if you got that right, but maybe that can be your problem. Just check it :) All through I'm not sure if this is true.. but give it a try :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...