Anders Moen Posted January 20, 2007 Share Posted January 20, 2007 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 More sharing options...
Escee Posted January 20, 2007 Share Posted January 20, 2007 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 More sharing options...
Lulzim Posted January 20, 2007 Share Posted January 20, 2007 which column is primary key?I guess the primary key column is not auto increment and you cannot insert a new row because the value in primary-key column must be unique. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 22, 2007 Share Posted January 22, 2007 $mysql_query = "INSERT INTO $mysql_tabell (tittel, forste, innhold, navn, epost, ip, dato) VALUES ('$tittel', '$forste', '$innhold', '$navn', '$epost' '$ip', '$dato')"; You're missing a comma between $epost and $ip. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now