Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2005, 11:39 PM
niy niy is offline
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default chap. 12 -cmstables.php

why do i get this msg when i get the file cmstables.php on browser?
'Column count doesn't match value count at row 1'
What does it means?

 
Old January 11th, 2005, 04:38 AM
Authorized User
 
Join Date: Dec 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, this type of error is typically shown because you're tying to insert data into a table, yet the number of columns doesn't match the number of values you're trying to insert. Take for example the last query in the code:

Code:
$sql = "INSERT IGNORE INTO
             cms_users
        VALUES (
             NULL,
             '$adminemail',
             '$adminpass',
             '$adminname',
             3)
        ";
$result = mysql_query($sql) or die(mysql_error());
Well, the above is trying to insert five values into the table. But if the table only has four columns, then it will fail. Another way for it to fail is if you forgot one of the commas, thus making it only four values that you are trying to input into a table that has five columns. This latter case is the mistake I most commonly made when I first got started. So, I try to be a little more consciencious with regards to the commas now. (Just remember to not put a comma after the last value. In the example above it would be after the number 3.)

 
Old January 12th, 2005, 08:37 AM
niy niy is offline
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well..thanks!!!what i've done was to get rid of the value '3' and i did success,there's was no error after that..is that what are u trying to tell me?or i get it wrong...

 
Old January 12th, 2005, 02:36 PM
Authorized User
 
Join Date: Dec 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by niy
 well..thanks!!!what i've done was to get rid of the value '3' and i did success,there's was no error after that..is that what are u trying to tell me?or i get it wrong...

well, then it sounds to me as if you might have your table setup incorrectly, because the value of 3 in this specific example is necessary. the table that these values are inserted into should have the structure like the following:

Code:
|--------------------------------------------------------------------------------
|  Field       |  Type          |  Null  |  Key  |  Default  |  Extra           |
|--------------------------------------------------------------------------------
|  user_id     |  int(11)       |        |  PRI  |  NULL     |  auto_increment  |
|  email       |  varchar(255)  |        |  UNI  |           |                  |
|  passwd      |  varchar(50)   |        |       |           |                  |
|  name        |  varchar(100)  |        |       |           |                  |
|  access_lvl  |  tinyint(4)    |        |       |           |                  |
---------------------------------------------------------------------------------

So...what this means is that if you did not include the '3', then you most likely don't have access_lvl as a field, and your script won't work correctly. Or the other case is that you do have access_lvl but not one of the others and then some of the data is in the wrong field; this would also not make your code work correctly. So...check your table structure with DESCRIBE cms_users; at the mysql> command prompt or use phpMyAdmin to check the structure. That should tell you a lot.






Similar Threads
Thread Thread Starter Forum Replies Last Post
chap 12 exer 2 harper BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 0 January 31st, 2008 10:19 AM
Chap 12 connection to a dbase jardbf BOOK: Beginning ASP 3.0 1 May 25th, 2006 11:01 AM
Chap 12 Project tracker - listboxes don't clear trancelife BOOK: Beginning Access 2003 VBA 1 February 14th, 2005 12:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.