Tuesday, January 15, 2008

Firefox 1.5 extensions for weather

The Linux CentOS 5.1 is still using Firefox 1.5.0.12 at the moment. To enhance Firefox usage there are Extensions that seems like little programs that can be added to Firefox. I can find the extensions at https://addons.mozilla.org/en-US/firefox/browse/type:1

I didnt have to search the web or memorise the URL link. Instead, in Firefox I on Tools -> Extensions and a nice dialog box appear where there is a hyperlink "Get more extension" at the bottom right. Click on this and a web browser brings you to the extension page.

I found a "forecast 0.9.6" that provides a nice display of the weather retrieved from accuweather.com web site. Currently it supports Firefox 1.5 -3 .0 which suits me just fine. At the firefox extension page, click on "Install now". Close all Firefox windows and open a new window. I am prompted with the option box for a default forecast location. I selected "Kuala Lumpur" and was given the following codes

ASI|MY|MY015|KUALA LUMPUR|


The Forecast appears at the bottom of Firefox where profiles can be customised by right clicking the extension.

It says Mostly Cloudy, 30 deg Celcius today. It also shows the weather for the next 2 days. Yippee now I can plan my travels.

Thursday, January 10, 2008

PHP commands to connect with MySQL

PHP and MySQL class just end over a 3 day duration. The syllabus covers the basic PHP command structures. This included variable usage, loops, conditional, user defined functions, pre-defined functions and database connectivity. A quick way to learn connectivity with MySQL is to already be familiar with SQL and relational database.

What is there to know about the database? I have a checklist below for learners to use
  1. Database
    1. Creating
    2. Deleting
    3. Selecting/Using a database
  2. Field types and their use
    1. Numerical - int, float
    2. Strings - char, varchar, text
    3. Time - date, timestamp
  3. Tables
    1. Creating
    2. Deleting
    3. Altering tables
  4. Records
    1. Inserting records
    2. Deleting records
    3. Editing records
    4. Retrieving records

Once the SQL syntax is known, the next step is to use PHP to execute the SQL commands on the MySQL database server. Among the basic commands that can be use is listed below:

  1. mysql_connect( ) - Open connection to a MySQL database server
    1. Description: returns FALSE if fail
      resource mysql_connect ([ string $server [, string $username [, string $password [, bool $new_link [, int $client_flags ]]]]] )
  2. mysql_query( ) - Send SQL commands to MySQL database server
    1. Description: returns FALSE on error
      resource mysql_query ( string $query [, resource $link_identifier ] )
  3. mysql_select_db( ) - Determine which database name to use on the MySQL database server
    1. Description: returns TRUE or FALSE
      bool mysql_select_db ( string $database_name [, resource $link_identifier ] )
  4. mysql_fetch_array( ) - Retrieve a record as an array
    1. Description: returns FALSE if no more records
      array mysql_fetch_array ( resource $result [, int $result_type ] )
  5. mysql_close( ) - Close a MySQL database connection
    1. Description: returns TRUE of FALSE
      bool mysql_close ([ resource $link_identifier ] )

That is all for now. I will write more in coming postings on PHP use with MySQL.

Monday, January 7, 2008

Top 10 fundamental PHP command to know for the Internet

Having had the computers set up with CentOS 5.1 last week, I am now prepared for the “PHP and MySQL database” training. Students started coming in at 8:00 AM today and some do not have practical programming skills.

There are many approaches to learning PHP. I find that the following are essential foundations
  1. Single and multi line comments.
  2. PHP files will usually have the extensions .php but there may be exceptions where the web server is set to use alternative extensions.
  3. Assigning and using variables. Variables can be in the form of numeric, strings or arrays and always begin with \$.
  4. Use of string functions to manipulate the string values. Some of the common functions are strlen – display the string length, strpos – display the string position in the array, strstr – finding a string within a string, substr – retrieve portions of a string.
  5. Sending HTML characters to the web server with echo and print commands.
  6. Sorting arrays with sort, by the values only (asort) or by the keys (ksort). Sorting can be done in the reverse too.
  7. Using loops to run statements is useful for repetitive task. Commands like while, do...while, for and foreach is rather useful.
  8. Conditional statements allow decisions to be made to run specific statements under certain conditions. Statements like if...elseif...else... and the switch is easy to understand.
  9. User defined functions can be declared any where before it is called.
  10. User input is through HTML form elements. PHP can use any of the following commands to retrieve the user input; $_POST, $_GET and $_ REQUEST arrays variables.
Knowing the above sets things right and you are ready to start PHP programming.

The start of 2008

This being the very first posting, I would like to say Happy New Year and welcome 2008! A warm welcome to all, this includes to all of my students.

One of the first Linux system (for 2008) I am downloading is the Linux CentOS 5.1 with 6 CDROMs and the additional 1 CDROM for net installation. This Linux is as close you can get to Red Hat Enterprise Linux quality. Managed to setup the network installation for all 24 PCs. This is needed as they are reinstalled almost 3 to 4 times a month. I will definitely write more on this in another posting.

The OpenOffice.org 2.3.1 on Linux CentOS 5 was giving trouble in one of the other Introductory OpenOffice.org classes. Yes, I do give trainings in OpenOffice.org but missed that last session. Will have to look into it. There are tons of guide on OpenOffice.org on the web and I wont replicate it here unless I find something really worth mentioning.

Blog Archive