(01-02-2017, 07:41 AM)neuron Wrote: it seems like your problem is in type of percentage column, in mysql you should define it as decimal(5,2)

Dear Neuron,

Thanks for the quick reply.

The problem is actually that the script code is computing the percentage correctly. My problem is inserting the computed value for score_percentage into the percentage column in the database table user_quiz_results.

As Neuron pointed out, your database table has a percentage column that looks like an integer data type. Your percentage is being calculated to two decimal places. So to insert a decimal into the database you need to define that column as a decimal data type, not an integer. Integers (int) values are whole numbers. Databases distinguish between integers and decimals, and a decimal cannot be an integer. Even 2.0 is not an integer. It is a decimal to one decimal place. Follow Neurons advice and change your column format in the database and see if you get any errors now.

(01-02-2017, 12:41 PM)PaulD Wrote: As Neuron pointed out, your database table has a percentage column that looks like an integer data type. Your percentage is being calculated to two decimal places. So to insert a decimal into the database you need to define that column as a decimal data type, not an integer. Integers (int) values are whole numbers. Databases distinguish between integers and decimals, and a decimal cannot be an integer. Even 2.0 is not an integer. It is a decimal to one decimal place. Follow Neurons advice and change your column format in the database and see if you get any errors now.

Thanks Paul for the explanation. I will make the change