localhost Posted July 16, 2006 Share Posted July 16, 2006 I've read up, and apparently it has to do with one of the columns auto incrementing, although I checked mine and can't find the problem. Any ideas? heres the code:[code]<?phpinclude('../inc/connect.php');/* ***** CREATE TABLE `categories` ***** */$ct = "CREATE TABLE `categories` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) NOT NULL, `description` varchar(255) NOT NULL, PRIMARY KEY (`id`))";$ctr = mysql_query($ct) or die(mysql_error());/* ***** CREATE TABLE `forums` ***** */$ct2 = "CREATE TABLE `forums` ( `id` int(11) NOT NULL auto_increment, `cat_name` varchar(70) default NULL, `title` varchar(255) NOT NULL, `description` varchar(255) NOT NULL, PRIMARY KEY (`id`))";$ctr2 = mysql_query($ct2) or die(mysql_error());/* ***** CREATE TABLE `posts` ***** */$ct3 = "CREATE TABLE `posts` ( `id` int(11) NOT NULL auto_increment, `tid` int(11) NOT NULL, `title` varchar(255) NOT NULL, `post` longtext NOT NULL, `poster` varchar(50) NOT NULL, `ip` varchar(40) NOT NULL, `date` varchar(20) NOT NULL, `le_user` varchar(50) default NULL, `le_time` varchar(50) default NULL, PRIMARY KEY (`id`))";$ctr3 = mysql_query($ct3) or die(mysql_error());/* ***** CREATE TABLE `topics` ***** */$ct4 = "CREATE TABLE `topics` ( `id` int(11) NOT NULL auto_increment, `fid` int(11) NOT NULL, `title` varchar(255) NOT NULL, `post` longtext NOT NULL, `poster` varchar(50) NOT NULL, `date` varchar(20) NOT NULL, `replies` int(11) NOT NULL, `ip` varchar(25) NOT NULL, `views` int(11) NOT NULL, `le_user` varchar(50) default NULL, `le_time` varchar(50) default NULL, PRIMARY KEY (`id`))";$ctr4 = mysql_query($ct4) or die(mysql_error());/* ***** CREATE TABLE `users` ***** */$ct5 = "CREATE TABLE `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(50) NOT NULL, `password` varchar(40) NOT NULL, `email` varchar(50) NOT NULL, `regip` varchar(40) NOT NULL, `regdate` varchar(20) NOT NULL, `user_level` int(11) NOT NULL, `postcount` int(11) NOT NULL, PRIMARY KEY (`id`))";$ctr5 = mysql_query($ct5) or die(mysql_error());$ip = $_SERVER['REMOTE_ADDR'];$date = date('m-d-Y');$password = sha1('yourforumsystem');/* ***** INSERT DEFAULT ADMIN ***** */$sql = "INSERT INTO users VALUES ('', 'Administrator' '$password', 'email', '$ip', '$date', '10', '0')";$sqlr = mysql_query($sql) or die(mysql_error());/* ***** INSERT DEFAULT CATEGORY ***** */$sql2 = "INSERT INTO `categories` (`id`, `title` , `description` ) VALUES ('', 'YourForumSystem', '');";$sqlr2 = mysql_query($sql2) or die(mysql_error());/* ***** INSERT DEFAULT FORUM ***** */$sql3 = "INSERT INTO `forums` (`id`, `cat_name` , `title` , `description` )VALUES ('', 'YourForumSystem', 'YourForumSystem', 'Thank you for installing YourForumSystem');";$sqlr3 = mysql_query($sql3) or die(mysql_error());/* ***** INSERT DEFAULT THREAD ***** */$sql4 = "INSERT INTO `topics` (`id`, `fid` , `title` , `post` , `poster` , `date` , `replies` , `ip` , `views` , `le_user` , `le_time` )VALUES ('', '1', 'Welcome to YFS', 'Thank you for installing YourForumSystem. You may now delete this post, edit it, and continue maintaining your forum with one of the best forum systems around, YourForumSystem.', 'Administrator', '$date', '0', '$ip', '0', NULL , NULL);";$sqlr4 = mysql_query($sql4) or die(mysql_error());?>[/code] Quote Link to comment Share on other sites More sharing options...
Gast Posted July 16, 2006 Share Posted July 16, 2006 What line/query gives you the error? Quote Link to comment Share on other sites More sharing options...
localhost Posted July 16, 2006 Author Share Posted July 16, 2006 No line...the title of this thread is the exact thing it says. Quote Link to comment Share on other sites More sharing options...
Joe Haley Posted July 16, 2006 Share Posted July 16, 2006 "INSERT INTO `topics` (`id`, `fid` , ... )VALUES ('', '1', ...Telling it to add ID with value '' may be causing the problem. Remove ID and its corrisponding value. Auto incriment fields are named that for a reson ;) Quote Link to comment Share on other sites More sharing options...
localhost Posted July 16, 2006 Author Share Posted July 16, 2006 no, neither way works! very odd... Quote Link to comment Share on other sites More sharing options...
Joe Haley Posted July 16, 2006 Share Posted July 16, 2006 add better error checking to see where the problem really is?eg: $sqlr3 = mysql_query($sql3) or die(mysql_error() . 'I died doing xxxx!');(for debugging purposes only, of course)and the problem may lay with:/* ***** INSERT DEFAULT ADMIN ***** */$sql = "INSERT INTO users VALUES ('', 'Administrator' '$password', 'email', '$ip', '$date', '10', '0')";$sqlr = mysql_query($sql) or die(mysql_error());as you dont explicitly define the colums the values go with. (should always, ALWAYS do that) Quote Link to comment Share on other sites More sharing options...
localhost Posted July 16, 2006 Author Share Posted July 16, 2006 /* ***** INSERT DEFAULT ADMIN ***** */$sql = "INSERT INTO users (`id`, `username`, `password`, `email`, `regip`, `regdate`, `user_level`, `postcount`) VALUES ('', 'Administrator' '$password', 'email', '$ip', '$date', '10', '0')";$sqlr = mysql_query($sql) or die(mysql_error(). 'I died doing a porno!');With that I got:Column count doesn't match value count at row 1I died doing a porno! Quote Link to comment Share on other sites More sharing options...
Joe Haley Posted July 16, 2006 Share Posted July 16, 2006 Do you validate user input? should always do that.oooh!$sql4 = "INSERT INTO `topics` (`id`, `fid` , `title` , `post` , `poster` , `date` , `replies` , `ip` , `views` , `le_user` , `le_time` )VALUES ('', '1', 'Welcome to YFS', 'Thank you for installing YourForumSystem. You may now delete this post, edit it, and continue maintaining your forum with one of the best forum systems around, YourForumSystem.', 'Administrator', '$date', '0', '$ip', '0', NULL , NULL);";Number of items in values is 1 less then the number defined!I love it when i find stupid mistakes like that xD Removes the stress of looking for em! Quote Link to comment Share on other sites More sharing options...
localhost Posted July 16, 2006 Author Share Posted July 16, 2006 What? They are the same, I am still having big trouble with this script and it's getting really annoying... Quote Link to comment Share on other sites More sharing options...
localhost Posted July 16, 2006 Author Share Posted July 16, 2006 omg, I never noticed, I was missing a comma after administrator. All works now, don't I feel stupid. Quote Link to comment 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.