Ian Anderson Gray

Technology, Music, Singing, Faith, Food & Drink, Politics

I’ve got a PHP script running which uses a lot of database from a MYSQL database. Unfortunately it throws a fatal error:

Fatal error: Allowed memory size of XXXX bytes exhausted (tried to allocate 4553173 bytes) in XXXX

Obviously substitute XXXX with whatever it says in your error message.

PHP has a max memory usage set in the php.ini file. It’s not good practice to increase this, but in some cases it can be a good idea to increase the limit on a script per script basis. Ideally you are better looking at your memory usage and try and decrease it that way, but sometimes this just isn’t possible, or you want to increase the limit temporarily so that you can debug. In this case, put the following at the top of your PHP script:

ini_set("memory_limit","16M");

In this case we have upped the memory limit to 16Mb. It’s best to only increase it a little as putting it up too high could fry your server, well perhaps not fry, but you know what I mean.

If you want to increase the memory limit on a site wide basis then you could add the following to your .htaccess file (assuming you’re using Apache):

php_value memory_limit 16M

There are so many techie websites out there to keep up with. My RSS feed reader seems to be stuffed full of them, although I do try and prune the list from time to time. However, over the past few years there are a few websites that I really do read on a regular basis. I thought I’d list them here:

  1. Lifehacker – A fantastic blog owned by Gawker on how to live your life with the help of technology, or with a techie twist.
  2. Boagworld – Blog written and owned by self-confessing geek and “wursel”, Paul Boag, co-founder of the web design agency, Headscape. He co-hosts the Boagworld podcast which is the longest running web design podcast.
  3. Smashing Magazine – Run by German company Smashing Media GmbH, Smashing Magazine remains one of the most comprehensive and beautifully built web design magazine. It’s very rare to find a mediocre article.

Quite an impressive alliteration, but it can be a little frustrating little thing which happens in many non-IE browsers. When you go from a page that doesn’t require scrolling (because all the content is one page) to a page that does, non-IE browsers such as Firefox shift the content to the left so that the scrollbars can be fit on the screen. In IE this doesn’t happen because the scrollbars always appear. To stop this shift from happening, the best and easiest way is to force all browsers to show the scrollbars at all times. Unfortunately the CSS code to do this isn’t particularly valid (it’s not what I’d call a hack either though), so I tend to add it at the end of my default Javascript file as a document write. Which ever way you want to do it is up to you.

The CSS style applies to the html element and sets the overflow-y to scroll:

html {overflow-y: scroll;}

If you want to add it to your javascript file, then put this at the end of it:

document.write("<style>html {overflow-y: scroll;}</style>");

And that’s it!

BlogI’ve been using the internet since 1994 when I started university. I built my first website using Fortune City back in 1996, got my first hosting account in 2000, set up a web design business in 2003, but despite many attempts I have never had a blog. Perhaps it’s because I am not a natural writer and not sure who my audience was. I think all these were barriers to me producing a blog. However, as I approach my 35th birthday, I just don’t see these as obstacles any more. At the end of the day my grammar might be bad, my prose awful, and perhaps no one will ever read this blog. I don’t really care, because I am writing this blog primarily for myself.

I’m always eager to learn new things, and what better place to note new discoveries than my own blog? When I discover a quick or new way of doing something I never seem to remember to write it down- so again, a blog seems like the best platform to do this on.

Another reason that I haven’t started a blog until now is because I have so many different interests that will seem completely unrelated to many potential readers. I’ll probably end up writing about my faith as a Christian, but I’m also a vegetarian who is passionate about food, drink, organic farming and local sourcing! I studied music at university and am a professional baritone (I studied voice at the Royal Northern College of Music), and I am a singing teacher. As I said before, I also set up a web design business back in 2003. I am definitely a geek interested in all things technology and in particular web development stuff.

So there you have it, my reasons for starting this blog at long last!