MyBB Community Forums

Full Version: Top stats - SQL Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,
I am trying to install Top stats #7
https://community.mybb.com/mods.php?acti...ad&pid=269

and I am getting this error
https://forum.robloxscripts.com/admin/in...ig-plugins
MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1366 - Incorrect integer value: 'NULL' for column 'gid' at row 1
Query:
INSERT INTO mybbqd_settinggroups (`gid`,`name`,`title`,`description`,`disporder`,`isdefault`) VALUES ('NULL','topStats','Top Stats','Settingsfor plugin Top Stats.',89,'0')


Do I have to change something and How?

Thanks
(2020-12-02, 08:48 PM)Mastersly Wrote: [ -> ]Hello everyone,
I am trying to install Top stats #7
https://community.mybb.com/mods.php?acti...ad&pid=269

and I am getting this error
https://forum.robloxscripts.com/admin/in...ig-plugins
MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1366 - Incorrect integer value: 'NULL' for column 'gid' at row 1
Query:
INSERT INTO mybbqd_settinggroups (`gid`,`name`,`title`,`description`,`disporder`,`isdefault`) VALUES ('NULL','topStats','Top Stats','Settingsfor plugin Top Stats.',89,'0')


Do I have to change something and How?

Thanks

Either disable MySQL strict mode or change "NULL" to 0 in the plugin file.
No.
Disabling MySQL strict mode will work, but if you can't (and it's better to not do that), remove 'gid' => 'NULL', from Topstats.settings.php :
$settings_group = array(
            'name' => 'topStats',
            'title' => $db->escape_string($lang->topStats),
            'description' => $db->escape_string($lang->topStats_Desc),
            'disporder' => $max_disporder + 1,
            'isdefault' => '0'
        );
This field is auto-increment, send 0 will create an error.

Same for all 'sid' => 'NULL',
(2020-12-03, 07:40 AM)Crazycat Wrote: [ -> ]No.
Disabling MySQL strict mode will work, but if you can't (and it's better to not do that), remove 'gid' => 'NULL', from Topstats.settings.php :
$settings_group = array(
            'name' => 'topStats',
            'title' => $db->escape_string($lang->topStats),
            'description' => $db->escape_string($lang->topStats_Desc),
            'disporder' => $max_disporder + 1,
            'isdefault' => '0'
        );
This field is auto-increment, send 0 will create an error.

Same for all 'sid' => 'NULL',

Why is it better to keep strict mode on? Genuinely asking as I've seen turning it off provided as a solution several times by developers on this forum.
I changed "NULL" to "0" at topStats.settings.php and topStats.tpl.php
thank you guys, it works now
(2020-12-03, 05:21 PM)Mastersly Wrote: [ -> ]I changed "NULL" to "0" at topStats.settings.php and topStats.tpl.php
thank you guys, it works now

Well Crazycat just said that you shouldn't do that as it will provide errors. I just want to make sure that doesn't happen down the road. Maybe once they answer we can get some more clarification.
(2020-12-03, 04:20 PM)tomjay78 Wrote: [ -> ]Why is it better to keep strict mode on? Genuinely asking as I've seen turning it off provided as a solution several times by developers on this forum.
Two reasons:
1. depending on your hoster, you can't disable that (we had examples of users in the community who can't because hoster refuse)
2. strict mode forces to have the most standard queries, which fully respect SQL language, so you're sure that the compatibilty with different engines (MySQL, mariaDB, potentially pgsql) exists and you won't have trouble with next versions of DB engines

And if strict mode becomes a standard, I think it's better to update the plugins to be compatible with standards rather than force users to change their server settings.

I did PHP developments in PHP 3, when PHP standard became 4, 5... then 8 now, I've updated my devels, I didn't explain how to force usage of old PHP versions.
(2020-12-03, 11:04 PM)Crazycat Wrote: [ -> ]
(2020-12-03, 04:20 PM)tomjay78 Wrote: [ -> ]Why is it better to keep strict mode on? Genuinely asking as I've seen turning it off provided as a solution several times by developers on this forum.
Two reasons:
1. depending on your hoster, you can't disable that (we had examples of users in the community who can't because hoster refuse)
2. strict mode forces to have the most standard queries, which fully respect SQL language, so you're sure that the compatibilty with different engines (MySQL, mariaDB, potentially pgsql) exists and you won't have trouble with next versions of DB engines

And if strict mode becomes a standard, I think it's better to update the plugins to be compatible with standards rather than force users to change their server settings.

I did PHP developments in PHP 3, when PHP standard became 4, 5... then 8 now, I've updated my devels, I didn't explain how to force usage of old PHP versions.

Very interesting. I do agree that it's mostly always best to adopt the new "standard". Thank you for the detailed explanation.  Big Grin