General help

 
 
Picture of Brian Y
Column count doesn't match value count at row 1 when trying to enroll
 

I originally posted this in the developer area as I thought it was related to a plugin I created but it appears to be system-wide issue happening with all enrollment methods. I wanted to post this here since it isn't directly related to development of a add-on.

I'm running build 2.5+ (20130621) and every time I try to enroll in a course I get the following error. This happens with a manual enrollment or via paypal or custom gateway.

Error writing to database

More information about this error

Debug info: Column count doesn't match value count at row 1

INSERT INTO mdl_user_enrolments (enrolid,status,userid,timestart,timeend,modifierid,timecreated,timemodified) VALUES(?,?,?,?,?,?,?,?)

[array (

0 => '4',

1 => 0,

2 => '2',

3 => 1372132800,

4 => 0,

5 => '2',

6 => 1372211793,

7 => 1372211793,

)]

Error code: dmlwriteexception

Stack trace:

    • line 426 of /lib/dml/moodle_database.php: dml_write_exception thrown
    • line 1089 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
    • line 1131 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
    • line 1294 of /lib/enrollib.php: call to mysqli_native_moodle_database->insert_record()
    • line 125 of /enrol/manual/manage.php: call to enrol_plugin->enrol_user()

 

The site was upgraded from 2.4.x to 2.5 on a dev server when 2.5 was first released. I could have sworn this was working after the upgrade (but that was over a month ago and am a little foggy.) I upgraded to the latest 2.5 build tonight to see if that would help with no success.

Does anyone have any idea what would cause this?

 
Average of ratings: -
Picture of Russell Smith
Re: Column count doesn't match value count at row 1 when trying to enroll
Group Developers

I've seen this kind of error when the default values don't exist or are invalid for columns that are;  in the table, but not in the insert statement.

Are you able to check the table definition in the database and compare that.  It may be an upgrade related issue, or something that has been wrong in the database for a long time that's only showing itself now.

So the tables definition would be useful to see.

Regards

Russell

 
Average of ratings: -
Picture of Brian Y
Re: Column count doesn't match value count at row 1 when trying to enroll
 

Thanks Russell, I didn't even think of that. Is there a way to see what the structure should be without installing a clean copy of 2.5?

Here is the current structure of mdl_user_enrolments

Field

Type

Allow Null

Default Value

id

bigint(10)

No

 

status

bigint(10)

No

0

enrolid

bigint(10)

No

 

userid

bigint(10)

No

 

timestart

bigint(10)

No

0

timeend

bigint(10)

No

2147483647

modifierid

bigint(10)

No

0

timecreated

bigint(10)

No

0

timemodified

bigint(10)

No

0

 
Average of ratings: -
Picture of Russell Smith
Re: Column count doesn't match value count at row 1 when trying to enroll
Group Developers

You can find the XML definition in lib/db/install.xml. I think.  Otherwise you'll have to use grep type search.  That gives the definition of the table for fresh install, which should be enough.

The only other advice I can offer is running checks on the mysql tables.

That's the end of the pointers I can offer, so sadly I'm going to have leave you alone to persue it by yourself after this.

Regards

Russell

 
Average of ratings: -
Picture of Brian Y
Re: Column count doesn't match value count at row 1 when trying to enroll
 

Russel, I appreciate the second reply.

I compared tables and they were fine (except one thing which I didn't realize until after the fact.)

I ended up copying the site over again to check after each step (copy, upgrade, etc.)

and found that it all worked correctly so it wasn't the upgrade. the problem was that I had some custom triggers on the table which I overlooked above that were causing the problems. Once I ironed out those issues everything is working great.

Thanks!

 
Average of ratings: -