Jump to content


Photo

sql issues, please help


  • Please log in to reply
5 replies to this topic

#1 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 14 April 2006 - 09:00 PM

hi,

I'm working on a install program for a program of mine and for some odd reason it will display this error when it tries to insert data into a newly made table.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Could not add data.
Column count doesn't match value count at row 1[/quote]

now here is the sql code I'm using:

mysql_query("INSERT INTO ebb_groups VALUES('1', 'Administrator', 'These are the people who are in charge. They have full power over the board.', '$user' '1', '1')") or die("Could not add data.<br>". mysql_error());

I am just stumped as to why this wont work, i mean i got this code right from phpmyadmin.

any help on this would really be great :)

thanks

#2 arifsor

arifsor
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts
  • LocationPakistan

Posted 14 April 2006 - 09:20 PM

[!--quoteo(post=364896:date=Apr 14 2006, 04:00 PM:name=darkcarnival)--][div class=\'quotetop\']QUOTE(darkcarnival @ Apr 14 2006, 04:00 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
hi,

I'm working on a install program for a program of mine and for some odd reason it will display this error when it tries to insert data into a newly made table.
now here is the sql code I'm using:

mysql_query("INSERT INTO ebb_groups VALUES('1', 'Administrator', 'These are the people who are in charge. They have full power over the board.', '$user' '1', '1')") or die("Could not add data.<br>". mysql_error());

I am just stumped as to why this wont work, i mean i got this code right from phpmyadmin.

any help on this would really be great :)

thanks
[/quote]

Your are entering 6 values in the table. Are you sure that your table contains 6 column.
---------------------------
Power Demand Respect
Arif Sorathia

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 April 2006 - 09:20 PM

At the risk of stating the obvious, does your newly created table contain six columns?

edit - too slow again :)
Legend has it that reading the manual never killed anyone.
My site

#4 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 14 April 2006 - 11:42 PM

yes it does.

btw the first col is the id which i set to auto incredment.

how about if i list the query that creates the new table:

CREATE TABLE `ebb_groups` (
  `id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Name` varchar(30) NOT NULL default '',
  `Description` tinytext NOT NULL,
  `Leader` varchar(25) NOT NULL default '',
  `Enrollment` tinyint(1) NOT NULL default '0',
  `Level` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1

if there is anything wrong there, please let me know.

edit: I got it to work, dont ask i just reworded the query and it worked.

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 15 April 2006 - 08:00 AM

Actually adding 5 values.

There's a comma missing between '$user' and '1'
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 15 April 2006 - 02:41 PM

yep i noticed that too later on :oops:, thanks guys its now working :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users