Jump to content

Column count doesn't match value count at row 1


localhost

Recommended Posts

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]
<?php

include('../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]
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

/* ***** 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!
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.