[HowTo] Stop phpmyadmin from asking username, password in localhost

Yesterday, I showed you how you can keep local installation of phpmyadmin from logging you out every few minutes. I took one more step and edited configuration to not ask me username, password at all. Now phpmyadmin never asks me for mysql username and password. Keep in mind if you follow this tutorial anyone would be able… Continue reading [HowTo] Stop phpmyadmin from asking username, password in localhost

Passing variable number of arguments to a function in PHP

We all know about functions and how we can pass arguments to it. But did you know that we can pass variable number of arguments in a function? Consider a function sum() which adds numbers passed into its arguments. Now we want it to add all the numbers passed onto the arguments. Eg; if we… Continue reading Passing variable number of arguments to a function in PHP

[HowTo] Remove admin bar from wordpress 3.1

The new admin bar in wordpress 3.1 is one good feature to have but sometimes its unwanted. For example you might already have some other kind of top bar with which admin bar may interfere. You can remove the admin bar by putting the following code in /wp-content/YOURTHEME/functions.php: if(function_exists(‘show_admin_bar’)){ show_admin_bar(false); }

[SOLVED] ‘Error at offset’ error in unserialize()

I came across this weird error in unserialize() where it refused to unserialize the serialized data. After hours of trying different things to solve it, finally converting the encoding worked. The solution to the problem is to use the following function instead of unserialize(): function safe_unserialize($str){ return unserialize( trim( mb_convert_encoding( $str,’auto’,’UTF-8′ ) ) ); }… Continue reading [SOLVED] ‘Error at offset’ error in unserialize()

[HOWTO] Fix Twitter clients (or PHP scripts) which use basic authentication.

As you probably know, Twitter completely ditched basic authentication method on August 31st, 2010. It now supports only OAuth method of authentication which complicates the coding process multiple folds. Scripts which were previously 20 lines long now span several files. While there are numerous advantage of Oauth like client doesn’t need to know your password,… Continue reading [HOWTO] Fix Twitter clients (or PHP scripts) which use basic authentication.

[HOWTO] Send emails(using mail function) from localhost in PHP through msmtp (using gmail account) on Linux

There’ve been lots of times when I wanted to use the mail() function on my local server. I am sure lots of you would’ve been wanting it too but most of you would’ve settled for PHPMailer or just used a web host to test the code instead. I myself had been doing the same until recently when I finally decided to… Continue reading [HOWTO] Send emails(using mail function) from localhost in PHP through msmtp (using gmail account) on Linux

[SOLVED]’Error establishing a database connection’ in wordpress

One of my clients got this error in his wordpress: Error establishing a database connection It is one of those vague errors which give very little information about what caused it. On going to /wp-admin, it gave error: One or more database tables are unavailable. The database may need to be repaired. I added “define(‘WP_ALLOW_REPAIR’,… Continue reading [SOLVED]’Error establishing a database connection’ in wordpress

[SOLVED] ‘Can’t connect to local MySQL server through socket’ error

Yesterday I got the error: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) when I ran the command mysql through terminal in Ubuntu 10.10 This error can also be linked to error in phpmyadmin: Connection for controluser as defined in your configuration failed. I figured out it was due to… Continue reading [SOLVED] ‘Can’t connect to local MySQL server through socket’ error

[HOW-TO] Back up all MySQL databases

To backup all or some of your MySQL databases, you’ll need mysqldump which comes bundled with mysql. If you have MySQL installed, you probably have mysqldump installed already. To backup all databases use the following command: In linux: mysqldump -uroot -ppassword –all-databases | gzip > /media/disk-2/db.sql.gz In Windows: mysqldump -uroot -ppassword –all-databases > db.sql This… Continue reading [HOW-TO] Back up all MySQL databases