We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Can't create custom fields: Exception Caught

How Do I?

davide_b's avatar
davide_b
6 posts
8 years ago
davide_b's avatar davide_b

Hello,

I’m trying to configure my local environment and I’m running into this issue: can’t create any Custom Field.

Details:

  • MAMP PRO 4.1.1 (running PHP 5.6.30 and MysQL 5.6.35)
  • Clean Install of EE 3.5.6 (also tried with EE 3.4.7)
  • MAMP is working fine with other type of CMS
  • Checked that InnoDB is the default engine for MySQL
  • EE Server Wizard says everything’s ok

I can access all sections of the CP and create entries (title only, since I can’t create fields). The error I get when I press “Create New” field is reported below. Any idea of what’s going wrong?

Thanks!

—

Exception Caught

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) ) ORDER BY Fieldtype_fieldtypes.name LIMIT 18446744073709551615’ at line 4: SELECT Fieldtype_fieldtypes.fieldtype_id as Fieldtype__fieldtype_id, Fieldtype_fieldtypes.name as Fieldtype__name FROM (exp_fieldtypes as Fieldtype_fieldtypes) WHERE ( binary Fieldtype_fieldtypes.name IN () ) ORDER BY Fieldtype_fieldtypes.name LIMIT 18446744073709551615

ee/legacy/database/drivers/mysqli/mysqli_connection.php:122

Stack Trace:

0 ee/legacy/database/drivers/mysqli/mysqli_driver.php(137): CI_DB_mysqli_connection->query(‘SELECT Fieldtyp…’)

1 ee/legacy/database/DB_driver.php(297): CI_DB_mysqli_driver->_execute(‘SELECT Fieldtyp…’)

2 ee/legacy/database/DB_driver.php(203): CI_DB_driver->simple_query(‘SELECT Fieldtyp…’)

3 ee/legacy/database/DB_active_rec.php(1219): CI_DB_driver->query(‘SELECT Fieldtyp…’)

4 ee/EllisLab/ExpressionEngine/Service/Model/Query/Select.php(45): CI_DB_active_record->get()

5 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(294): EllisLab\ExpressionEngine\Service\Model\Query\Select->run()

6 ee/EllisLab/ExpressionEngine/Service/Model/DataStore.php(240): EllisLab\ExpressionEngine\Service\Model\DataStore->runQuery(‘Select’, Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))

7 ee/EllisLab/ExpressionEngine/Service/Model/Query/Builder.php(156): EllisLab\ExpressionEngine\Service\Model\DataStore->selectQuery(Object(EllisLab\ExpressionEngine\Service\Model\Query\Builder))

8 ee/EllisLab/ExpressionEngine/Service/Model/Query/Builder.php(75): EllisLab\ExpressionEngine\Service\Model\Query\Builder->fetch()

9 ee/EllisLab/ExpressionEngine/Controller/Channels/Fields/Fields.php(312): EllisLab\ExpressionEngine\Service\Model\Query\Builder->all()

10 ee/EllisLab/ExpressionEngine/Controller/Channels/Fields/Fields.php(170): EllisLab\ExpressionEngine\Controller\Channels\Fields\Fields->form()

11 [internal function]: EllisLab\ExpressionEngine\Controller\Channels\Fields\Fields->create(‘1’)

12 ee/EllisLab/ExpressionEngine/Core/Core.php(189): call_user_func_array(Array, Array)

13 ee/EllisLab/ExpressionEngine/Core/Core.php(94): EllisLab\ExpressionEngine\Core\Core->runController(Array)

14 ee/EllisLab/ExpressionEngine/Boot/boot.php(151): EllisLab\ExpressionEngine\Core\Core->run(Object(EllisLab\ExpressionEngine\Core\Request))

15 admin.php(143): require_once(‘…’)

15 admin.php(143): require_once(‘…’)

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

The appearance is that you are either missing files, PHP cannot read the files, or your installation did not complete successfully and your database has integrity issues. Let’s eliminate them in reverse order: can you browse to your exp_fieldtypes table and let me know its full contents?

       
davide_b's avatar
davide_b
6 posts
8 years ago
davide_b's avatar davide_b

Hi Derek, thank you for your reply.

This is what the table exp_fieldtypes looks like (hope this is readable in some way).

Thanks.

Name Type Collation Attributes Null Default Comments Extra

1 fieldtype_idPrimary int(4) UNSIGNED No None AUTO_INCREMENT 2 name varchar(50) utf8_unicode_ci No None
3 version varchar(12) utf8_unicode_ci No None
4 settings text utf8_unicode_ci Yes NULL
5 has_global_settings char(1) utf8_unicode_ci Yes n
PartitionsDocumentation No partitioning defined! Information Table comments:

Space usage Data 16 KiB Index 0 B Total 16 KiB Row statistics Format Compact Collation utf8_unicode_ci Next autoindex 15 Creation May 02, 2017 at 10:36 AM

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

That’s the info for the table, I’m looking for the contents. Can you run the following and paste the results in a code block? (See the “Use Markdown” link below for formatting options)

SELECT * FROM exp_fieldtypes;
       
davide_b's avatar
davide_b
6 posts
8 years ago
davide_b's avatar davide_b

Hi Derek, ok I hope this is the correct info: (I’m inexperienced with databases)

fieldtype_id name version settings has_global_settings 
1 select 1.0.0 YTowOnt9 n 
2 text 1.0.0 YTowOnt9 n 
3 textarea 1.0.0 YTowOnt9 n 
4 date 1.0.0 YTowOnt9 n 
5 email_address 1.0.0 YTowOnt9 n 
6 file 1.0.0 YTowOnt9 n 
7 grid 1.0.0 YTowOnt9 n 
8 multi_select 1.0.0 YTowOnt9 n 
9 checkboxes 1.0.0 YTowOnt9 n 
10 radio 1.0.0 YTowOnt9 n 
11 relationship 1.0.0 YTowOnt9 n 
12 rte 1.0.1 YTowOnt9 n 
13 toggle 1.0.0 YTowOnt9 n 
14 url 1.0.0 YTowOnt9 n
       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Yes, that is what I’m looking for, thanks. That table looks correct. This next bit is a little technical, but since this is running on your machine I can’t help diagnose directly. Some of our own team uses MAMP without any issues, so I’m really not even sure where to start looking at what might be wrong, so I just want to know where it’s failing. Essentially your installation is reporting that there are no fieldtypes installed, leading to the empty IN() clause in the query, which is invalid in MySQL. We can do these one at a time to minimize confusion.

In a new PHP enabled-template, add:

<?php
$addons = ee('Addon')->installed();

if (empty($addons))
{
 exit('failed');
}

echo "<pre>";

foreach ($addons as $addon)
{
 echo $addon->getName().': ';
 echo ($addon->hasFieldtype()) ? 'Has' : 'Does not have';
 echo " fieldtype\n";
}
?>

Access the template and cut and paste the results here.

       
davide_b's avatar
davide_b
6 posts
8 years ago
davide_b's avatar davide_b

When I visit the template I see this: Channel: Does not have fieldtypenComment: Does not have fieldtypenFile: Does not have fieldtypenFilePicker: Does not have fieldtypenMember: Does not have fieldtypenRelationships: Does not have fieldtypenRich Text Editor: Does not have fieldtypenSearch: Does not have fieldtypenStatistics: Does not have fieldtypen

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Did you cut and paste, and include the \ in echo " fieldtype\n";? Those should have each been output on a line by themselves, with fieldtype spelled correctly. 😉

Your installation is missing all fieldtypes, including from add-ons that are showing as installed that include fieldtypes. Replace the code above with:

<?php
echo "<pre>";
var_dump(glob(PATH_ADDONS.'*/ft.*.php'));
?>

Pase the results, as before.

       
davide_b's avatar
davide_b
6 posts
8 years ago
davide_b's avatar davide_b

Ouch! I copy-pasted from the notification email where the “/” disappeared… Anyway, with the new code I only see this:

array(0) { }

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Ok you are somehow missing all of the fieldtype files. Look in your system/ee/EllisLab/Addons folders (checkboxes, email, toggle, and url for instance all are fieldtypes). The complete list is:

/system/ee/EllisLab/Addons/checkboxes/ft.checkboxes.php
/system/ee/EllisLab/Addons/date/ft.date.php
/system/ee/EllisLab/Addons/email_address/ft.email_address.php
/system/ee/EllisLab/Addons/file/ft.file.php
/system/ee/EllisLab/Addons/grid/ft.grid.php
/system/ee/EllisLab/Addons/hidden/ft.hidden.php
/system/ee/EllisLab/Addons/multi_select/ft.multi_select.php
/system/ee/EllisLab/Addons/radio/ft.radio.php
/system/ee/EllisLab/Addons/relationship/ft.relationship.php
/system/ee/EllisLab/Addons/rte/ft.rte.php
/system/ee/EllisLab/Addons/select/ft.select.php
/system/ee/EllisLab/Addons/text/ft.text.php
/system/ee/EllisLab/Addons/textarea/ft.textarea.php
/system/ee/EllisLab/Addons/toggle/ft.toggle.php
/system/ee/EllisLab/Addons/url/ft.url.php

If they exist, check file permissions on them to make sure they are readable. If everything is there and permissions are intact, then you have something in your environment that is preventing PHP’s glob() function from working properly, or in your config that is setting paths incorrectly. If none of the above reveal the issue, do a gut check, in the PHP enabled template:

<?php
var_dump(PATH_ADDONS);
?>

That should be a correct full server path to the system/ee/EllisLab/Addons folder.

       
davide_b's avatar
davide_b
6 posts
8 years ago
davide_b's avatar davide_b

Hi Derek, all the files and permissions were there, and the php code returned the correct path, but I always got the error.

After some trial-and-error I found that the environment didn’t like the name of the project folder in the path, something like: Site 1 [EE]/def/dest

Without the square brackets in the path, it’s working — well, it’s also working with empty brackets [], but NOT with something between the brackets, like [aaa].

I don’t know if this makes sense to you, or if it sounds like a total beginner mistake… anyway I’m happy it’s working now 😊

Thank you for your quick support!

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Ah, the unix-based glob treats brackets as special characters, so PHP’s glob() function does likewise, and thinks your directory name is looking for a regex-like character class, e.g. folder[name] would match foldern, foldera, folderm, and foldere, but not foldername. So ExpressionEngine is unable to find your add-on folders. Super edge case, and I’d wager that using brackets in file paths is not common, I’d just avoid that and use dashes, underscores, or subfolders to keep your directories organized.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.