Category Archives: Technical

“Uncaught exception Fuel\Core\Database_Exception: No MySQLi Connection”

Problem

Upon trying to run some migrations in FuelPHP via command line with Oil I ran into this error message containing the error

Uncaught exception Fuel\Core\Database_Exception: No MySQLi Connection

I discovered that when running from the command line my normal php.ini was not being run. PHP was using the defaults, including the default mysql socket which was in the wrong place.

Solution

In my case I created a symlink to redirect which seems to have done the trick. I am running Mamp on OS X in default locations so your directories may differ.

cd /var/mysql

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock

There may be a better fix and this may be a symptom of something else being ‘off’.  I initially created a /etc/php.ini with the proper socket location directive but this did not work out properly, possibly due to permissions or something.

“No input file specified.” with .htaccess on FCGId

In my case I was trying to get PHP playing nicely with my FuelPHP app running on Apache under FCGId configured via Virtualmin.  My .htaccess looked like:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

The fix was annoyingly simple and took me hours of digging to discover.  Insert a question mark before the slash after index.php like this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Alternatively you can also get it to work WITHOUT adding in the question mark by changing from FCGid to CGI (if configuring via Virtualmin: Server Configuration: Website Options: PHP script execution mode from “FCGId” to “CGI wrapper”) but if you want it to work in FCGid mode you will need the question mark.  I do not know why this is the case though.