Remove admin-bar WordPress 3.1

Posted: March 18th, 2011 | Author: | Filed under: Wordpress | No Comments »

WordPress 3.1 is released and comes with many new features. One of them is the extra admin bar visible at the front-end of your website when user are logged in:

adminbar

Not everyone is happy with this new feature. Here is the way to disable it for project:

Open functions.php and add:

// Disable admin-bar from showing on your blog
wp_deregister_script('admin-bar');
wp_deregister_style('admin-bar');
remove_action('wp_footer','wp_admin_bar_render',1000);

Disable resizing textarea’s in Chrome and Firefox 4

Posted: March 18th, 2011 | Author: | Filed under: CSS | No Comments »

When I was building a new form for a new project today I was having some problems with the resize option for textarea’s in Chrome (update: and Firefox 4). Every form with a textarea messes up the entire website layout by resizing this field.

Example:

textarea {
	resize: none;
}

I know this can be an usability thing for Chrome and Firefox users, but I think when you make your textarea large enough there should be no problem at all.


Facebook PHP SDK for Canvas and FB Login

Posted: January 10th, 2011 | Author: | Filed under: Facebook, PHP | Tags: , , , | 3 Comments »

This is a short article on how to best implement the Facebook PHP SDK for two integration methods: Canvas applications and external websites offering Facebook Login to their visitors. The difference is not very well documented in the example provided with the SDK. Read the rest of this entry »


Htaccess redirect with a space in the URL

Posted: April 6th, 2010 | Author: | Filed under: Etcetera | No Comments »

I discovered something new today how you can use a space in a htaccess file:

How can you safely redirect web site traffic from your old pages to the new pages without losing your high search engine rankings?
You can do this by using a “301 redirect“.

But what do you have to do if there is a space in the old URL:

^about nostylesheets.html$

Normally I would use this to make the URL working:

^about%20nostylesheets.html$

But this doesn’t work.
To make an URL working you just have to use quotes to make this URL working:

"^about nostylesheets.html$"

The jQuery/PHP Validator

Posted: April 6th, 2010 | Author: | Filed under: JS, PHP | 1 Comment »

Check out our demo which uses the jQuery as well as the PHP validator:
http://open-source.yes2web.nl/php-validator/demo1/validator-form.php

We the developers  already know about the famous jQuery validator and about all the wonderful things it is capable of. But we also know that this validation is only on the client side.

What about server side validation on form input? Isn’t that important too? Of course it is. And that is exactly why we’ve come up with the following solution for this issue: The php validator. This validator consists of  a class which contains a collection of methods similar to the jQuery validator. This way, we have validation on both client- and server sides using exactly the same rules and error messages.

Our PHP validator is based on the bassistance jQuery validator found at: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Read the rest of this entry »


Thoughts on php’s print_r

Posted: March 25th, 2010 | Author: | Filed under: PHP | No Comments »

Just a quick quick question: Why does php’s print_r function, which is pretty usefull to all, feature a $return (optional) argument? Not a question about it’s usefulness, but rather the choice to include this into the print_r. I would prefer to see an sprint_r variant behaving like

function sprint_r($sIn){
     return print_r($sIn, true);
}

to conform to choices made for (s)printf. While on the subject, why not include a fprint_r as well (useful perhaps for logging):

function fprint_r($oFP, $sIn){
     return fwrite($oFP, sprint_r($sIn));
}

and perhaps a vprint_r to complete the symmetry, though I have no clue as to what it should do :) .


Character encoding in MySQL

Posted: February 27th, 2010 | Author: | Filed under: MySQL | No Comments »

Just a quick note on character encoding in MySQL, use the following to force MySQL into using UTF-8 for ever!

PHP

In your PHP, always use the following immediately after you set up your connection.

  • mysql_set_charset(‘utf8′, $oDB);
  • mysql_query(‘SET NAMES \’utf8\”);

The tricky bit lies in your MySQL configuration file:

my.cnf

Add the following lines:

[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
default-collation = utf8_general_ci

This tells MySQL that the client (which is either PHP or the system) expects UTF-8. If you don’t tell MySQL this, a mysqldump will produce ANSI and an import from the command line will result in double encodings.

And don’t forget to use utf8_general_ci for all databases, tables and fields!


Mobile web – introduction

Posted: July 31st, 2009 | Author: | Filed under: Mobile Browsers | No Comments »

I’m not a marketing specialist, but I can see a lot of things change very quickly when we talk about mobile devices. Since its invention the mobile phone became indispensable in our lives. The mobile phone is used mainly for business purposes, but this is changing day by day: The market is moving fast to consumers too. With more people using a high-end phone, the capabilities for mobile web design give developers the opportunity to focus on this group of people as well.

Many people think it’s hard to make their website suitable for mobile devices, but this isn’t the case at all. In this article I’ll introduce a couple of things you should consider before developing a mobile website. In a future article I’ll give some hands-on advice on where to start. Read the rest of this entry »


__PHP_Incomplete_Class Object

Posted: July 21st, 2009 | Author: | Filed under: PHP | 3 Comments »

Just a quick note, as I could not find a satisfactory answer fast enough googling the web. I got a (not so) nice __PHP_Incomplete_Class Object notice the other day, happily programming until that moment. Such a notice indicates that somewhere (very likely in your session) a class has been unserialized that php does not know how to handle. This means that php knows which class the unserialized data should be, but cannot find the class declaration. It may happen using this type of code:

session_start();
class SomeClass { ... }
$_SESSION['some_instance']; // which is a SomeClass assigned in some previous request

Depending on the implementation of the class, e.g. use of SPL, this will result in a __PHP_Incomplete_Class Object. To fix this, tell php what the class is/can do before unserializing, i.e. move session_start below the class declaration.


MySQL Substr count

Posted: July 17th, 2009 | Author: | Filed under: MySQL | 7 Comments »

Recently I needed to create an SQL statement which was to count the occurences of a character inside a particular database field. For example, you could store the tags connected to a single db-record in a semi-colon (;) separated column in the record. To get the number of tags for this record straight from the database, we would thus like the number of semi-colons in the field (+1) as an indicator for this count. Since MySQL5 does not have a standard function for this (similar to PHP’s substr_count()), I had to find something of my own. Read the rest of this entry »