Filipino Programmer | Philippines

Just another Filipino Programmer’s blog by Nick Fernandez III, on web development using PHP in LAMP framework and random information about everything I would tought interesting on and off the IT world.

Random Bytes:
Reaction ng mga texters kapag nawala ang cellphone nila. 1% of them: Shit! Mahal pa naman ang bili ko dun! 2%: Naman! Unlimited pa naman ako. 97% Gosh! Ang number ni "Nick Fernandez", andun! Cute pa naman yun. Hehehe.

Archive for the ‘Programming’


Disable all form elements in Javascript

Disabling all form elements in javascript is quite easy, you only need to loop inside a form object and change the disabled property to true or false. Below is the function you can use to call to enable/disable form elements.

function formElementsDisabled(frm,val){
  frmElem= frm.elements;
  for(i=0;i
      

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati

Regular Expression on PHP

One of the good point of choosing PHP as your language in creating dynamic web applications is its versatility on string processing, like PERL which is the leading language for string processing, PHP provides a powerful functions and capability in dealing with string. I decided to do a collection of useful regular expressions used on web for certain string matching.

Here are the collections of regExpr:
Domain

"/^(http:\/\/)?([^\/]+)/i"

This will extract the host name from the URL
Example implementation

$url = "http://www.knicks49.com/aboutme/";
preg_match("/^(http:\/\/)?([^\/]+)/i",$url, $result);
$host = $result[2];
print $host;

The output is www.knicks49.com. Alternatively you can also use this expression to extract the last two segments of the domain name.

preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $result);
print "domain name is: {$result[0]}";

The output will produce domain name is: knicks49.com
(more…)

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati

Cross-browser Keypress Event Handler


While doing a javascript cross-browser check of an web application. I have encountered a javascript error in handling keypress events on Firefox and Opera browser. Apparently the previous programmer who created the web application did not took into consideration Firefox and Opera browsers. The code is only working under IE. This is the part of the javascript code which is for IE only.

if (event.keyCode==13){
   [do something here...]
   return true;
}

(more…)

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati

Static IP(Dedicated IP) Vs. Shared IP

I have accidentally encountered this two type of IP Address today while I am setting up a Hosting Server (Shared Hosting).  In the Web there are two basic IP types existing. This is a Static and Shared. Before I compare the two, let me first explain what an IP Address is. Well to explain it in lay man’s term an IP Address is like a phone number for computer. This a how other computers on the Web is identified. For further definition of IP Address please click here.

Now with that in mind people on Web ussually access a website using domain names, for example www.knicks49.com that domain name will be resolved in an ip address similar to this 66.249.89.104. So if you type in 66.249.89.104 directly into yhe address bar of your browser you will arrive at the home page. This is the basic idea of how ip address are used on Web. Now let me explain a different scenario. Some hosting server host multiple websites on a single server which we call Shared Server, this server uses a single ip to hosts multiple sites, basically when a request is received on a shared server the domain name is resolved into ip address, the server then realize that someone is looking for a domain hosted on the server and returns back the page to the person requesting it. You can always reach a site which has a static IP address by using its IP address alone, but you can’t reach a site using a shared IP address by typing in the IP address alone because when you type in a shared IP address you arrive at the server but the server doesn’t know which site you want because you haven’t told it which domain name you want.

Here are important reasons why do you need Static IP Address.

  • Websites using SSL Encryption
  • Websites offering anonymous FTP transfers.
  • Websites without Domain Names

SSL Encryption, requires a site to have a unique ip address to process encryption process. Anoymous FTP transfers (basically where anyone can download files off the site)  also requires a unique IP Address. And lastly when websites does not want to buy a domain name and is hosting their website on a shared server, must have a static ip address to view their websites. Other that these 3 reasons there is no need for a site to have its own IP address.

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati

CFMX7 and Apache Server Problem

Below are errors and solutions on the problems I have encountered today. I am deploying a Coldfusion MX application which uses Apache as the web server and MySQL as the database server. First I will list down an important setup steps to follow when installing Coldfusion MX to use Apache as the Web Server.

I will explain the Web Server Selection of the setup process.

Web Server Selection

You’ll notice that there are no Web Servers/Sites listed here, but don’t worry — this is OK. We have to tell ColdFusion we want to use the Apache Web server. To do this, click the Add button.

Web Server Configuration

 Make sure you select Apache as your Web Server and, if you left the defaults for your Apache installation, you can use “C:\Program Files\Apache Group\Apache2\conf” for the Configuration Directory and “C:\Program Files\Apache Group\Apache2\bin\Apache.exe” as the Directory and file name of server binary.

When you’re done, click the OK button. You screen should now look like this:

Web Server Selected

Once you’ve made your selection, click the Next button to continue the process. A few more selections will be presented but the next screens are self explanatory.

Below are errors and solutions I have encountered

When running htt�://localhost/CFIDE/administrator/index.cfm and encounters this error:
Failure Description: Your browser prompts you to save the .cfm file to your computer.
Resolution: First restart Apache service. If failure still exists, check Apache’s httpd.conf file to make sure Coldfusion module is being loaded, to locate the Coldfusion module entry find this string:

LoadModule jrun_module "C:/CFusionMX7/runtime/lib/wsconfig/1/mod_jrun20.so"

also check is the DirectoryIndex has “index.cfm� added on the lists, if not add it. After that just restart the Apache Server.

To connect to a MySQL 4.1 or 5 database from ColdFusion MX:

Download a current, stable version of the MySQL Connector J JDBC driver, available at: http://dev.mysql.com/downloads/
Note: Connector/J version 3.1.11 and higher cannot be used with ColdFusion MX 7 because of MySQL bug 13469. Connector/J 3.1.10 should be used instead for ColdFusion MX 7 until this MySQL bug is fixed. All Connector/J version 3.0 releases and all version 3.2 releases work with ColdFusion MX 7.

  1. Extract the mysql-connector-java-3.{n}-bin.jar file from the downloaded archive file.
  2. Save the mysql-connector-java-3.{n}-bin.jar file in the cf_root/WEB-INF/lib directory.
  3. Restart the ColdFusion MX server.
  4. Add a new data source to the ColdFusion MX Administrator, using the driver option Other.
  5. Enter the JDBC URL:
    jdbc:mysql://[host]:[port]/[database]
  6. Enter the Driver Class:
    com.mysql.jdbc.Driver
  7. Complete username/password, and adjust other data source settings, if needed.
  8. Submit the data source for verification.

Bookmark This!

del.icio.us Digg Google StumbleUpon Technorati


Filipino Programmer | Philippines
The views expressed here reflect the views of the author alone.
HOME SUBSCRIBE WORK EXPERIENCE ABOUT ME



Filipino Programmer | Philippines © 2007 All Rights Reserved. Using WordPress Engine
Entries (RSS) and Comments (RSS).

Creative Commons License