Chris Hope's LAMP Blog's Image

Chris Hope's LAMP Blog

http://www.electrictoolbox.com
More about this blog
Latest Post
11 Mar 2010
Total Posts
120
Readers
887
Liked
0
Disliked
0
Views-Per-Post
07.39
vote up
0
vote down

jQuery JSON Ajax requests and caching

Last week I wrote how to load JSON data with jQuery, PHP and MySQL, noting at the end that there can be some caching issues which may or may not be a problem depending on your implementation. I look at this here and a possible solution.
Mar 12 2010 04:08 AM
vote up
0
vote down

Disabling PHP short tags in an Apache .htaccess file

PHP code in a script is commonly delimited by opening <?php and closing ?> tags but there are also the older short open tags like this <? There are instances where you may need to disable short tags as shown in this post and using an Apache
Mar 10 2010 10:04 PM
vote up
0
vote down

Load data into MySQL with foreign key constraint issues Part 2

I recently showed how to load data into MySQL with foreign key constraint issues when loading a backup from tab delimited text files. This post provides a BASH command line script to generate the SQL to load all the files to save some time.
Mar 09 2010 10:24 PM
vote up
0
vote down

Using Javascript's setTimeout() with variable parameters

Javascript's setTimeout function executes code after a specified amount of time but can only handle constant parameters. This post looks at how to pass variable parameters to setTimeout.
Mar 08 2010 10:46 PM
vote up
0
vote down

Handling errors when connecting to a database using PHP PDO

PHP's PDO database abstraction class offers a better way to connect to databases than the mysql_* etc style functions, or using a 3rd party database library. This post looks at handle errors when connecting and a follow up post later this week will look
Mar 07 2010 09:50 PM
vote up
0
vote down

Disable auto renew at GoDaddy

I use GoDaddy to register my domain names and secure certificates. When a new product is bought from GoDaddy it will be default set to auto-renew. I prefer to manually renew everything and this post shows how to disable auto renewal at GoDaddy. Following
Mar 06 2010 08:42 PM
vote up
0
vote down

Show an icon in an HTML input using CSS

Today's post is a relatively simple tip to add an icon into an HTML text input using CSS so that it sits inside the input box and the text does not appear over it at all.
Mar 05 2010 11:33 PM
vote up
0
vote down

How to put text right next to a SilverStripe template placeholder

I needed to put some text directly next to a placeholder in a SilverStripe template and couldn't find the answer in the online documentation or the SilverStripe book, but perhaps I missed it. In any case, I worked it out from a user comment so show here
Mar 05 2010 07:18 PM
vote up
0
vote down

Internet Explorer 7 issues with jQuery animation and position:relative

Internet Explorer 7 can have issues with rendering jQuery animations if some of the properties that are to be animated have not already been set with CSS, and the containing block has the position property set to "relative".
Mar 04 2010 10:20 PM
vote up
0
vote down

Exiting from within a PHP exception

This is the final post in my series about PHP exceptions and looks at how when an exception occurs, script execution may continue depending on how the exception is handled.
Mar 03 2010 11:13 PM
vote up
0
vote down

Randomly ordering data with MySQL with a random value column

It's possible to order data randomly with MySQL using ORDER BY RAND() or doing a count on the table and then using LIMIT to choose a random offset. However neither of these are suitable for dealing with large tables with many rows. In this post I present
Mar 02 2010 09:59 PM
vote up
0
vote down

VPS.NET to increase node size

VPS.NET are celebrating their first birthday by increasing the memory and CPU per node at some stage this week. Their VPS system works on a system of nodes where you can easily add or remove nodes to a virtual server at any time.
Mar 02 2010 07:54 PM
vote up
0
vote down

Load JSON data with jQuery, PHP and MySQL

This post shows how to populate a select box based on the value of the another, by getting JSON data with jQuery from a PHP script that gets the data from a MySQL database.
Mar 02 2010 05:19 AM
vote up
0
vote down

Monthly Roundup - February 2010 - Statistics

My monthly stats round up posts a summary of the most read posts over the previous month, numbers of visitors to the blog and any changes I have made over the month that may have affected visitor numbers etc. This is the monthly stats roundup for
Mar 02 2010 03:15 AM
vote up
0
vote down

Converting an array to JSON data with PHP

PHP's json_encode function converts a PHP variable into a JSON string which can then be used in Javascript, for example using jQuery's JSON functions. This is easy to do and I'll be combining the two together in tomorrow's post to show how to fetch data
Mar 01 2010 06:13 AM
vote up
0
vote down

Monthly Roundup - February 2010 - Post Summary

At the start of each month I post a complete list of articles posted in the previous month. This is the monthly summary for February 2010. This is followed up on the second day of the month (i.e. tomorrow) with statistics relating to visitor numbers and
Feb 28 2010 06:30 PM
vote up
0
vote down

Remove webkit border on input on focus

When a text input has focus it is slightly highlighted in Firefox and Internet Explorer and much more so in the the webkit based browsers (Chrome, Safari, Konqueror). Normally this behavior should be left as-is but I personally recently needed to prevent
Feb 27 2010 09:30 PM
vote up
0
vote down

jQuery's Facebox and Google Maps

On my soon to be launched New Zealand Running Calendar, I have the location map of the running event on a Google Map. This map can be viewed either on a regular page or via an AJAX call in a jQuery Facebox popup window. However I had issues with the map
Feb 26 2010 10:37 PM
vote up
0
vote down

Fetching data using PHP and PDO with bound placeholders

This post shows how to fetch data from a MySQL database using PHP's PDO library with bound placeholders. This is a fairly basic tutorial and the functions used in it will be used in a post tomorrow titled "Load JSON data with jQuery, PHP and
Feb 25 2010 07:12 PM
vote up
0
vote down

Catch mutiple exception types with PHP

PHP's try..catch can be used to catch multiple exception types. If the try block could cause one of several different exceptions they can each be handled separately with their own catch section.
Feb 25 2010 10:50 AM
vote up
0
vote down

Solution for "Error saving content" when saving an error page in SilverStripe

I was getting the error message "Error saving content" when publishing an error page in the SilverStripe CMS and couldn't work out why. The changes were being displayed in the front end so the error message seemed kind of odd.
Feb 24 2010 08:08 PM
vote up
0
vote down

Another alternative for randomly ordering data with MySQL

This time last week I mentioned I had another solution to pulling records out of a table at random with MySQL (compared with ORDER BY RAND() and LIMIT). However I've had some issues with the actual "randomnesss" where it seems to favour a
Feb 23 2010 11:07 PM
vote up
0
vote down

How to log into SilverStripe if you've lost the login details

If you have lost the admin login details for a SilverStripe installation and sending an email to reset the password is not working, there is a default admin account that can be enabled. After logging in, reset the regular administrator's details and then
Feb 23 2010 06:54 PM
vote up
0
vote down

Load JSON data with jQuery

JSON data can be retrieved using AJAX from a server either using jQuery's .ajax() function or the shorthand $.getJSON() function. If you have retrieved a JSON string without having jQuery decode it automatically using one of these functions, the string
Feb 22 2010 10:02 PM
vote up
0
vote down

Style the #SilverStripeNavigatorMessage in SilverStripe

When logged into the SilverStripe CMS admin or viewing a SilverStripe on a development site there's a box with a red background that is positioned absolutely showing whether this is the published or the draft version of the site. This post shows how to
Feb 22 2010 07:57 PM
vote up
0
vote down

Get the filename extension with PHP

I've covered how to get the filename and directory name from a full path with PHP before and did include a section which happened to include how to get the filename extension as well, but I continue to find myself unable to remember the name of the
Feb 22 2010 07:39 AM
vote up
0
vote down

Which directory is that bash script in?

There may be times when you need to know the actual location a BASH script is located within the script. This can be done with a combination of the $0 value and the dirname command.
Feb 22 2010 03:33 AM
vote up
0
vote down

.htaccess condition to prevent missing CSS, JS, image urls being parsed by SilverStripe

The default .htaccess file for SilverStripe runs all URLs that do not belong to actual files on the filesystem through the Sapphire framework. This means that if a request is made for a CSS file that does not exist, for example, it will be run through
Feb 21 2010 01:30 PM
vote up
0
vote down

Cross browser transparency

The CSS3 standard introduces the opacity property for making elements opaque or transparent. Older browser also have support for opacity using various other properties and, in the case of Internet Explorer, filters. This post looks at how to achieve
Feb 20 2010 06:49 AM
vote up
0
vote down

Files and permissions when installing SilverStripe

When you open up your web browser to a SilverStripe install for the first time there's an installation process that needs to be run. This requires several permissions to be set correctly when running on a *nix based host so this post has the commands
Feb 19 2010 08:17 PM
vote up
0
vote down

parseInt('08') returns 0 with Javascript

I came across a rather interesting problem with the Javascript parseInt() function a couple of days ago; if the value is a zero padded string and is '08' or '09' then parseInt() will return 0. This post looks at why 0 is returned and how to solve the
Feb 18 2010 10:33 PM
vote up
0
vote down

The SilverStripe book and Amazon delivery estimations

I ordered the SilverStripe book &quot;SilverStripe: The Complete Guide to CMS Development&quot; from Amazon.com on Friday last week and received it yesterday morning. I'll review it properly once I've finished reading it cover to cover (probably b
Feb 18 2010 08:27 PM
vote up
0
vote down

Extend PHP's exception object

PHP's Exception object can be extended (just as any class can be that is not declared final) which means different exception types can be thrown that handle the exception differently.
Feb 17 2010 11:27 PM
vote up
0
vote down

What files can be deleted after installing SilverStripe?

After installing SilverStripe there are a whole bunch of files in the site's root directory which are no longer needed and can be deleted. This post lists which files are safe to delete.
Feb 17 2010 07:12 PM
vote up
0
vote down

MySQL's LIMIT syntax can be slow for large offsets

A couple of weeks ago I posted an alternative to ORDER BY RAND() when using MySQL which uses MySQL's LIMIT syntax to jump to a record chosen at random based on the number of records in the table. I received a Tweet earlier this week which pointed out
Feb 16 2010 10:07 PM
vote up
0
vote down

Added comments, new bookmarking, BSA asynchronous ad code

This is a quick post to talk about some changes I made to my blog last night. These include adding comments using Disqus, replacing the Add to Any bookmarking and subscribe widgets with static buttons, and changing the Buy Sell Ads over to
Feb 16 2010 08:00 PM
vote up
0
vote down

Dynamically load a Javascript file with jQuery

jQuery's $.getScript() function is a shorthand wrapper to $.ajax() which easily allows remote Javascript to be loaded into the current page.
Feb 15 2010 11:03 PM
vote up
0
vote down

Different home page and sub pages with SilverStripe

The SilverStripe CMS makes it very easy to have a slightly different layouts between pages by creating another page type and using $Layout with different layout templates. I did this for the Fabco Ltd website which is a small website with a larger main
Feb 15 2010 06:50 PM
vote up
0
vote down

PHP shebang

I've posted a number of times in the past about how it is possible to run PHP scripts from the command line and here dedicate a post to showing how a PHP script can be run by adding a shebang line and running it as if it were any other command.
Feb 14 2010 10:10 PM
vote up
0
vote down

Upcoming SilverStripe Posts

If you follow my blog you will have seen in the last three days a few posts about the SilverStripe CMS system. I've just started using it and am creating a big portal site with it along with converting some of my existing websites and creating some new
Feb 14 2010 08:04 PM