
June 5th, 2008 by

Jon Moffet
There are times when you need a function that can detect strings which contains onlyalphabetic characters. While is_numeric can validate a given string contains numeric character, there are no is_* function variation exist which can do the same for alphabetic strings.
However, you can still test for alphabetic string using ctype_alpha() function. Example usage :
CODE:
-
if (ctype_alpha($testcase)) {
-
echo "The string $testcase consists of all letters.\n";
-
} else {
-
echo "The string $testcase does not consist of all letters.\n";
-
}
-
}
Good luck, and happy coding.
Posted in Uncategorized |
2 Comments »

June 4th, 2008 by

Jon Moffet
I found out that truncating SQLite database is a little bit different from its MySQL counterpart. Here's how to truncate SQLite database from command line
CODE:
-
sqlite your_database.db
-
sqlite> DELETE FROM some_table;
after that, dont forget to execute VACUUM to compact the database :
Posted in Uncategorized |
No Comments »

April 30th, 2008 by

Jon Moffet
Quick PHP Code is back! So appology for the delays caused due to some unavoidable circumstances. We are no back!
Posted in Uncategorized |
No Comments »

May 18th, 2007 by

Jon Moffet
file_get_contents() is a function use to read an entire file to a string. It is occasionally use as a convenient function to retrieve web pages from remote servers in trivial PHP scripts.
However, some web servers has disabled the URL retrieving capabilities in file_get_contents() function for security reasons, this caused scripts written with this function throws out an error which can render the whole web application useless in that particular web server.
To remedy this, you can replace file_get_contents() function with PHP cURL calls. Here's how you can do this.
Before
file_get_contents
After
CURL solution
Although the cURL version seems to be a little bit longer, it is guaranteed to work across servers which place restriction on file_get_contents() and file() function. The use of libcurlemu ensures that the script can work even on a server which doesn't have the PHP CURL extension, which makes this a universal solution for retrieving remote web content from PHP application.
Tags: curl, php, remote, security, php scripts, web hosting, web
Posted in Uncategorized |
4 Comments »

May 16th, 2007 by

Jon Moffet
If you're writing web application that has access to database, then you should be aware that those application are susceptible to SQL Injection attacks which leave information stored in your database vulnerable from a malicious cracker.
This can led attacker to access private areas in your web application, steal sensitive information, erase your database or alter certain information in the database for his own gain. Therefore it is prudent to safeguard your web application by filtering unsafe input variables before inputting them into SQL statements.
How crackers perform SQL Injection
Here is a list of common SQL injection technique employed by malicious users across the internet.
Another good read that I suggest is SQL Injection by examples which provide great explanation of how SQL Injection attacks are performed.
Tags: sql, mysql, injection, security, sqlite
Posted in Uncategorized |
4 Comments »