Snippet IT IT News, Programming, Internet and Blogging

7Jul/090

BigDump: Alternative to phpMyAdmin to Import/Restore Large Database

Recently I was facing problem on restoring database with a lot of data into MYSQL using phpMyAdmin. The restoring process keeps interrupted due to the connection between browser and server time's timeout and also due to the timeout in PHP script. Only partial data is restored and I kept dropping the database, increase PHP timeout, increased memory limit, and tried to restore again. But it still failed.

4May/090

PHP: How to Protect Password in Database – Password Hashing

If you are a programmer, you may have developed applications that store users or your customers' information in database. How to store users' or customers' sensitive data (especially password) might be an issues for most programmer. How do you ensure and convience that your users or customers'  password are actually secured?

Password 

25Apr/090

PHP: Format integer into number of decimal places

Previous I have written an article about formating interger into number of decimal places in Java. The main reason to store money value in integer in to prevent loss in precision. For example the actual value for 12.33 in float could be 12.3333333333...; while 1233 in integer is always 1233.

Today I will be showing you the same code but in PHP language. I know you can do the same thing with PHP's number_format(), but you will need to cast the integer into float first before past the money value into the number_format() function. Therefore there are possibles of lose in precision.

24Apr/090

PHP: session_start() – No such file or directory error

Have you encountered the following PHP error (or something similar) before in your Windows Vista?

Warning: session_start() [function.session-start]: open(C:\Users\YOURNAME\AppData\Local\Temp\php\session\sess_ficdel21e6lupsojqdk62ofts5, O_RDWR) failed: No such file or directory (2) in C:\webapp\folder\index.php on line 24

The solution to the above error is really simple. Simply re-create the folder C:\Users\YOURNAME\AppData\Local\Temp\php\session\. For some reason, you or your Windows Vista (e.g. during a disk cleanup) may deleted all the files and folder under C:\Users\YOURNAME\AppData\Local\Temp\ and this is the main reason PHP can't find the correct location to create its temporary file for new session.

10Apr/090

PHP: Short URL Algorithm Implementation

Few months ago, I introduced a simple algorithm that allow users to implement their own short URL into their system. Today, I have some spare time so I decided to write the short URL algorithm's implementation in PHP.

At first, we define a function called shorturl() that receives a URL as the input and returns an array that contains 4 hashed values (each 6 characters).

function shorturl($input) {
   ...
  // return array of results
}
11Feb/090

Regular Expression Test Tool

When writing a software, you may need to use regular expression to filter some string values or to validate some input strings. It is quite troublesome to test the correctness of the regular expression pattern that you have designed. You will need to compile you source code, execute the compiled binary, perform some steps until to the point that make use of the regular expression. It takes a lot of time to do the trial and error especially if you are not very familiar with regular expression.

18Apr/080

Google Adsense Search Result in Worpress

Those who have Google Adsense account and Wordpress may want to add Google Adsense Search function to his or her Wordpress blog. Besides the search functionality from Google to search the pages within your site and Internet, you also can earn money from the Adsense advertisement within the Google Search result.

5Apr/080

Replace Wordpress’ more tag with advertisement code

Sometime we want to insert Google Adsense or other advertisement code into middle of a post in Wordpress. Replacing the <!--more--> code with Google Adsense or other advertisement code is one of the way.