Posts Under ''

Escape special characters from String in Java + Mysql

Class StringEscapeUtils java.lang.Object extended by org.apache.commons.lang.StringEscapeUtils public class StringEscapeUtils extends java.lang.Object Escapes and unescapes Strings for Java, Java Script, HTML, XML, and SQL. escapeJava public static void escapeJava(java.io.Writer out, java.lang.String str) throws java.io.IOException Escapes the characters in a String using Java String rules to a Writer. A null string input has no effect. Parameters: out […]

Read more »


Validate email using regular expression in PHP

Regular expressions, also referred to as regex or regexp, provide a concise and flexible means for identifying strings of text, such as particular characters, words, or patterns of characters. Using below regex example, you can validate an email address – eregi — Case insensitive regular expression match $email = "someone@example.com"; if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+ (\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { echo […]

Read more »


Image Upload and Proportional Resize with php

PHP has the ability to upload files(images/docs) using the multipart/form-data protocol. To upload files, in a form you have to specify enctype="multipart/form-data", so that you can upload files. // This is the temporary file created by PHP $uploadedfile = $_FILES['image']['tmp_name']; // Create an Image from it so we can do the resize $image = $_FILES['image']; […]

Read more »


To parse a date which may be delimited with slashes, dots, or hyphens:

<?php // Delimiters may be slash, dot, or hyphen $date = "04/30/1973"; list($month, $day, $year) = split('[/.-]', $date); echo "Month: $month; Day: $day; Year: $year \n"; ?>

Read more »


Retrieving Values from Result Sets

The ResultSet interface provides methods for retrieving and manipulating the results of executed queries, and ResultSet objects can have different functionality and characteristics. These characteristics are result set type, result set concurrency, and cursor holdability. A table of data representing a database result set is usually generated by executing a statement that queries the database. […]

Read more »