PHP database can’t connect to localhost but works

There are many reasons for this, so first check that MySQL/MariaDB is running properly, that you are using the correct credentials and that the the appropriate user@localhost has access.

Also check you aren’t using skip-name-resolve and bind-address in your my.cnf file if accessing from outside of the localhost. These are things you will find with a google search.

Apart from this one other reason why will work and localhost will not work is if you are using something other than the default socket=/var/lib/mysql/mysql.sock location in your my.cnf.

If that is the case, you’ll need to update the relevant default_socket= parameter in php.ini (for each driver) to match that socket – see the entries under my.cnf [mysql] and [mysqld] sections for the socket parameter. This is more likely to occur if you are using MariaDB for example.

$_SESSION global is empty

If you find that your global $_SESSION variable is empty there can be several reasons, here are a few:

  • The session.save_path is invalid (does not exist) or is not writable.
  • The session.cookie_secure is set to true but you not using a secure site (SSL/https).
  • The session.cookie_domain is set to a domain that does not match your site – very common if setting up a dev or test environment from a production site with a public domain.

Fixing Mac Book Pro – No Internal Speakers

This happens on occassion on the Mac Book Pro – You lose the internal speakers and are only left with digital out. A sign this has occurred is that the red light in the headphone port (where you plug in your headphones) will be on.

There are numerous ways to try to fix this, anything from system preference tweaks all the way to opening up your Mac Book.

Here’s the simplest thing you can try (and it does seem to work with a bit of persistence):

  1. Open System Preferences > Sound
  2. Plug in your headphones as you won’t have control over the volume/mute of the digital output
  3. Once headphones shows up on the list, move the volume slider up and down and check/uncheck the mute button.
  4. Unplug your headphones
  5. Check if digital out has disppeared and been replaced by Internal Speakers.
  6. Rinse and repeat. Note it can take several attempts before this works. For example, after 3 times, I finally had internal speakers appear for a second then disappear back to digital out. On the fifth attempt, internal speakers appeared again and this time stayed. Basically what you are doing is trying to get the Macbook to recheck its sensors and correctly revert to internal speakers.

Good luck.

Mahara Class ‘HTMLPurifier_Config’ not found

This error relates to a call to the clean_html function in lib/web.php which loads HTMLPurifier. Turns out that due to a bad .gitignore file where all files with the name config.php were being ignored, the file:


Wasn’t in the install and caused this error. Fixing up the .gitignore file to only ignore the root level config.php (/config.php/) resolved the issue and allowed the missing config.php file to be deployed on the target install.

Alfresco could not resolve view error

In Alfresco Share (share.log), I kept getting this error and couldn’t figure out what was causing it:

ERROR [] javax.servlet.ServletException: Could not resolve view with name 'user/guest/dashboard' in servlet with name 'Spring Surf Dispatcher Servlet'

After a lot of fruitless google searching and trial and error, I finally tracked it down to items missing share-config-custom.xml, so if you get something similar, review your share-config-custom.xml in detail.