MyBB Community Forums

Full Version: Can someone please teach me the very basics of MYSQL Error?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Firstly, this is not an issue, it just my desire to learn, and the fact that I'm not doing much right now, except typing and digesting a salad, by the way, I didn't like the mozzarella topping.

There is one thing that fascinates me about problems and that is a specific type, and it seems so basic but most people get lost right away when facing SQL errors, yet the error is stating what the issue is, the problem is interpreting the Error and the Query.

The error tells us what is happening.

What is the Query saying, does that tell us what to run?

This is just a conversation starter, but I'd love to obtain basic information, from the staff and pros who know best.
you might have already seen common error messages & fixing such errors

as you might be knowing,
there are different types of databases.
their coding languages have many differences.

in general, most of the plugins are coded for MySQL type of databases
we often see incompatibility problems with some other types of databases

we also see problems due to strict mode (security method) set for database servers

though you said basics, that itself could be a vast subject as
it can be difficult to differentiate basic SQL & high level SQL

see also few search results
Man, that is such a great answer, thanks m. It is a valid answer to the question.

To any of the experts who care to get involved in this conversation, this is an EXAMPLE of a database error:

SQL Error:
1366 - Incorrect integer value: '' for column 'pid' at row 1

Query:
INSERT INTO mybb_pollvotes (vid,uid,voteoption,dateline,pid) VALUES (0,2220,127,0,'')



my question is, when the error states "Query:

is the error stating that the webmaster must run this query

(vid,uid,voteoption,dateline,pid) VALUES (0,2220,127,0,'')


in mybb_pollvotes?

for example.
No.

So here's how that query works.

The syntax for an INSERT query is as follows:

INSERT INTO table_name.table_with_prefix (optional, collumn, names, if, being, selective) VALUES (as, per, set in, php)

Your query is:

INSERT INTO mybb_pollvotes (vid,uid,voteoption,dateline,pid) VALUES (0,2220,127,0,'')

Which basically means, insert the data into the mybb_pollvotes table, using the columns vid, uid, voteoption, dateline, pid. Now, you'd assume that the *id columns would have a number in them. That just makes sense; so when you try to insert '' into the pid column, it complains. Because it's not an integer (or a number - an integer, INT, is a number).

Which is why you're getting the error Incorrect integer value: '' for column 'pid' at row 1 - because you're not inserting an integer.
It is important to note that the above error will not be displayed _always_, as I believe this is rather a common issue with your DB sytem set to strict mode (as mentioned by .m.). You can read more regarding strict mode in the web, the following is just one (imo) rich explanation:
https://stackoverflow.com/questions/1381...is-enabled
(2019-01-04, 05:34 AM)Omar G. Wrote: [ -> ]It is important to note that the above error will not be displayed _always_, as I believe this is rather a common issue with your DB sytem set to strict mode (as mentioned by .m.).

If the table is set to NOT NULL and you're trying to insert a non-integer it will complain.
@Ben Even if strict mode is disabled?
(2019-01-04, 05:41 AM)Omar G. Wrote: [ -> ]@Ben Even if strict mode is disabled?

Yes, because the type of content is incorrect. An int is a number, only ever a number.
(2019-01-04, 03:44 AM)Ben Cousins Wrote: [ -> ]No.

So here's how that query works.

The syntax for an INSERT query is as follows:

INSERT INTO table_name.table_with_prefix (optional, collumn, names, if, being, selective) VALUES (as, per, set in, php)

Your query is:

INSERT INTO mybb_pollvotes (vid,uid,voteoption,dateline,pid) VALUES (0,2220,127,0,'')

Which basically means, insert the data into the mybb_pollvotes table, using the columns vid, uid, voteoption, dateline, pid. Now, you'd assume that the *id columns would have a number in them. That just makes sense; so when you try to insert '' into the pid column, it complains. Because it's not an integer (or a number - an integer, INT, is a number).

Which is why you're getting the error Incorrect integer value: '' for column 'pid' at row 1 - because you're not inserting an integer.

Thank you ben, so eye opening! I appreciate the insight, and will evaluate your solution until I fully grasp the solution you supplied.