3raser Posted February 6, 2010 Share Posted February 6, 2010 Why do I keep getting this error?... Incorrect integer value: '' for column 'id' at row 1 Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/ Share on other sites More sharing options...
trq Posted February 6, 2010 Share Posted February 6, 2010 Code would help. Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007781 Share on other sites More sharing options...
3raser Posted February 6, 2010 Author Share Posted February 6, 2010 <?php mysql_connect("-","-","-") or die("Connection failed!"); mysql_select_db("-") or die("Database fail!"); $username = $_POST['username']; $password = $_POST['password']; if (!$username || !$password) die (" <form action='register.php' method='POST'> <b>Please note that the following characters: `*<>() will be removed upon registering.</b><br /><br /> * Username: <input type='text' name='username' maxlength='12'><br /><br /> * Password: <input type='password' name='password' maxlength='20'></div><br /><br /> <input type='submit' value='Register'> </form>"); if (strlen($password)<=3) { echo "Password must be MORE then 3 characters long! <a href='register.php'> << Back </a>"; } else { if (strlen($username)<=1) { echo "Username must be MORE then 1 characters long! <a href='register.php'> << Back </a>"; } else { $ip = $_SERVER['REMOTE_ADDR']; //protection $before = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE'); $after = array('', '', '', '', '', '', '', '', '', '', '', '', ''); $output = str_replace($before, $after, $username); //protection $output3 = str_replace($before, $after, $password); //protection $output4 = str_replace($before, $after, $email); //protection $output2 = str_replace($before, $after, $signature); $query = mysql_query("SELECT * FROM users WHERE username='$output'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo "This username already exists!"; } else { //write $write = mysql_query("INSERT INTO users VALUES ('', '$output', '$output3')") or die(mysql_error()); echo "<div class='box'>Thank you for registering $output! You can now use your account in the game."; } } } ?> The code, specifically: mysql_query("INSERT INTO users VALUES ('', '$output', '$output3')") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007782 Share on other sites More sharing options...
trq Posted February 6, 2010 Share Posted February 6, 2010 You likely have an auto incrementing id field, and your code is trying to insert an empty string into it. You need to explicitly name the fields you are inserting into, and simply leave out the id field. eg; mysql_query("INSERT INTO users (fld, fld2) VALUES ('$output', '$output3')"); Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007784 Share on other sites More sharing options...
3raser Posted February 6, 2010 Author Share Posted February 6, 2010 That gives me this... Column count doesn't match value count at row 1 Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007787 Share on other sites More sharing options...
3raser Posted February 6, 2010 Author Share Posted February 6, 2010 Bump Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007895 Share on other sites More sharing options...
3raser Posted February 6, 2010 Author Share Posted February 6, 2010 BUMP.... Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007898 Share on other sites More sharing options...
premiso Posted February 6, 2010 Share Posted February 6, 2010 Column count doesn't match value count at row 1 That is impossible to get with Thorpes code, post the query you are really trying to run. Quote Link to comment https://forums.phpfreaks.com/topic/191127-why-do-i-keep-getting-this/#findComment-1007909 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.