Thursday, May 28, 2009

Calling JavaScript Function from hyper link

While working on my project, i was thinking of a way to inform a user to click on a certain link before clicking on a particular. So, Javascript was an option to do that now the question arises

How to execute a java script function by clicking on link?



first thing i do is call the function after the href tag like
<a href="funciton_call();"> but this does not work...
first i was getting syntax error than i don't know what i did i started getting

permission denied

403 error....

then i have to call my might

Google

to rescue me out of this situation...

Google gave me couple of articles related to this issue but there is one article that explain the lots ways of achieving this or why use Javascript in this post i like to summarize article " Links & Javascript living together in harmony" by Jeff Howden.


To ways to open a link in a new window




  • <a href="#" onclick="window.open('somedoc.html', 'newWindow')" >click here</a>
    Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938

  • calling by pseudo-protocol method

    <a href="JavaScript:window.open('somedoc.html', 'newWindow')">click here</a>
    Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938



calling by pseudo-protocol method cause a line break if user try to open a web-page in a new window by doing shift+click .

In this article author explains the implication arises from using these methods.he said if you disable java script the first method will cause the browser to jump to the top of document and second method does nothing.

Another way to open a new window for non-Javascript user is?



<a href="somedoc.html" target="newWindow" >click here</a>

and if user want to open a pop up window, he can do this by using onclick event

<a href="somedoc.html" target="newWindow" onclick="window.open(this.href, this.target); return false"
>click here</a>
Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938


Calling a function from a href tag for javascript compatible browser



<a
href="js_required.html" onmouseover="window.status = 'click here'; return true;"
onmouseout="window.status = '';" onclick="myFunction(); return false;"
>click here</a>

Calling a function from a href tag for non-javascript compatible browser



<a
href="js_required.html"
onmouseover="window.status = 'click here'; return true;" onmouseout="window.status = '';" onclick="return myFunction()">click here</a>
Howden J. 2002,"Links & JavaScript Living Together in Harmony",sydney,29-05-09,http://www.evolt.org/node/20938

Monday, May 18, 2009

Referential integrity constraint in MySQL

Hey guys!
This post is response to article "Using foreign keys and referential integrity in MySQL" at http://www.builderau.com.au/program/mysql/soa/Using-foreign-keys-and-referential-integrity-in-MySQL/0,339028784,339237600,00.htm

Following is a summary of how to use foreign key constraint in MySQL.

Three condition should met in accordance to use foreign key constraint among tables in MySQL:-


  • INNOBD type

    Both table should be of INNOBD type


  • Field my be indexed

    Field used in the foreign key constraint should be indexed.


  • Data type should be similar

    Data types of the field used in the foreign key relationship should be similar.



Syntax for this:-
lets assume we have two tables parent and child.

  • Creating parent table

    create table parent(id int NOT NULL Auto_Increment PRIMARY KEY,f_name varchar(15))ENGINE=INNODB;


  • Createing child table

    create table child(id int NOT NULL,l_name varchar(15))ENGINE=INNODB;

    .

  • adding foreign key constraint

    ALTER TABLE child
    ADD INDEX(id),
    FOREIGN KEY(id) REFERENCES parent(id);


    Note: we can define foreign key constraint while defining table as:

    create table child(id int NOT NULL,l_name varchar(15),INDEX(id),FOREIGN KEY(id) REFERENCES parent(id));



Significance of Foreign key Constraint!


Foreign key constraint help us in achieving Referential Integrity in MySQl. With help to reduce redundancy in database as record can be added to reference(child) table is corresponding field value exist in the refereed(parent) table.


Lets add values in to the table created above
insert into parent values (1,'John'),(2,'Peter'),(3,'William');
Now if this command is executed
insert into child values (4,'walter');
this will give an error as there is no record in parent table with field id value 4.



ON DELETE CASCADE on UPDATE CASCADE

MySQL require above keyword in foreign key constraint if user want to delete corresponding record in child table when a record in parent table is deleted.

syntax for this:

create table child(id int NOT NULL,l_name varchar(15),INDEX(id),FOREIGN KEY(id) REFERENCES parent(id) ON DELETE CASCADE ON UPDATE CASCADE);

Friday, May 15, 2009

Page rank algorithm!

Hey Guys!
this is a part of my assignment for other subject (Unix-system programing) . This article is about page rank algorithm used by goggle to find out relevance of page when the search query is process. i thought i might share it with you all as it describe the process how goggle process search query in simple language.Below is the summary of this article written by Ian Rogers, those who are interested can click on the link at the end of this post to read original article......

Ques1) what is Page Rank?


Ans 1) Page rank can be simply defined as one of the methods used by the Goggle to determine the relevance or importance of web-page and it changes whenever goggle does re-indexing. Page rank does not tell anything about content of size of page, the language or text.
whenever a search query is process by goggle, goggle looks at the url of the page displayed by browser striping off everything down the last "/", if the Toolbar PR of that parent exist goggle subtracts 1 from it and display Toolbar PR of this page. If Toolbar PR of that parent does not exist it jump to parent's parent's page and subtract 2 and so on all the way up to root of the site before displaying PR in Toolbar.


Page rank can also be define as vote of all the other pages on Internet, revealing about the importance of that page it is calculated by following formula.

  • PR(A)=(1-d)+d(PR(T1)/C(T1)+........PR(Tn)/C(Tn)


where:-


  • PR(Tn):- self importance of each page.
  • C(Tn):- vote spread by page to its outgoing links.
  • PR(Tn)/C(Tn)- if the page contains back links from page the share of vote that
    page will get is "PR(Tn)/C(Tn).
  • d - this is multiplying factor
  • 1-d - to keep sum of all pages equal to 1 this multiplying factor is introduced.



Total of 13 example are explained in this article from simple to complex in ascending order.Describing how PR in calculated in various scenario? and how can we increase the PR of the home page?


link:- http://www.ianrogers.net/google-page-rank/

Friday, May 8, 2009

How to give <TAB> in Html

Hey guys!
if you all are struggling with this question of how to give <TAB> in Html
the solution is :-
use <t> element,write your text and end with </t> it easy...

JUST KIDDING! HE. HE.



is given in web page by using non-breaking space &nbsp; character followed by the actual text. for example:

example(not follwed by &nbsp;) will look like

example

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( will shown as)

       example

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;example ( will displayed as)
                 example

so more &nbsp; more is the spacing of character/word from preceding characters/words


                                                     reference (http://webdesign.about.com/od/intermediatetutorials/qt/tiphtmltab.htm)
http://www.cookwood.com/html/extras/entities.html

Helpful tips for desgining a website


  • Points to be kept in mind while designing web page:-

    • Website should be easy to read.
    • Frames and Table should be avoided because of following reason:-

      • They slow down the uploading of web pages.

      • Web pages with frames and table receive low ranking in search engine and your work may get unnoticed.

      • CSS is much better and flexible way and frames and table are history.



  • Website should be readable.

    Short paragraphs, small text size and contrast between text color and background of web pages.Second thought should be given how web page will look like when the user print them, color choice which look good on screen may not be easy to read when printed out.


  • How the attract visitors to the website.

    • Meta tags.

      As the search engine scans the meta tags for finding searched string, so meta tags must be included in the web pages.

    • Keywords should be used for naming the web pages.

    • Lots of images and tables should be avoided as they made scanning of the web pages harder.




  • Web site address

    There are lots of places on the world wide web where web sites can be hosted for free. Web site name should be easy to understand and spell and its good if it include keywords in it.




                                                                 reference
                                 (http://nzwebs.com/webcoach.htm)


Sunday, April 26, 2009

Effective interaction between php and MySQL

As i know how to make HTML forms,and have moderate knowledge of PHP and MySQL so its time to try out some data sharing between php and MySQL.


  • Establishing a connection
    First of all we have to build a connection between php functions and MySQl and the command to do that is:-
    mysql_connect("Hostname","username","password");

  • Selecting a database
    Once the connection is established an appropriate database is selected and the command for that is:-

    mysql_select_db("database_name",connection_variable);

  • Executing the mysql queries
    mysql_queries is executed by the following command:-

    mysql_query( mysql_query variable, connection variable);



( Meloni , Julie C. 2005," Sams teach yourself PHP,MysQL and Apache all in one", Sams , ed:2.)

Friday, April 24, 2009

Exploring MySQL

Before jumping on to project, i decided to do some data manipulation in MySQL so that i have better understanding of it syntax. This turn out to be good decision as i have work on any Database software for about 6 month, after a long hit and trial i learn to following things about MySQL database:-


  • MySQL Data Types

    • Numeric data types

      • INT
      • TINYINT
      • SMALLINT
      • MEDIUMINT
      • BIGINT
      • FLOAT(M,D)
      • DOUBLE(M,D)
      • DECIMAL(M,D)

        Note: term signed and unsigned can be used in numeric data types

    • Date and Time types

      • DATE
      • DATETIME
      • TIMESTAMP
      • TIME
      • YEAR(M)

    • String Types

      • CHAR(M)
      • VARCHAR (M)
      • BLOB or TEXT
      • TINYBLOB or TINYTEXT
      • MEDIUMBLOB or MEDIUMTEXT
      • LONGBLOB or LONGTEXT
      • ENUM



  • First thing is to create our database which can be done by executing following command:-
    CREATE DATABASE [IF NOT EXISTS] "database name"
    [[default] CHARACTER SET "character set name"]
    [[default] COLLATE "collation name"]

    (Sheldon, Robert and Moes Geoff 2005,"Beginning MySQL",JohnWiley and sons,pg 140).

    or simply:-

    CREATE DATABASE "database name";
    if CHARACTER SET AND COLLATE are not define that MySQL will use the default value.

  • use this command is used to change database.The syntax of this is:-
    mysql> use datbase_name
    .
    Note: this command does not followed by semi colon(;) like other commands


  • For creating table the command is:-
    mysql>CREATE TABLE table_name (column name column type);

    Note: table would be created in the selected database,make sure the right database is selected.
  • For entering data in to table the command is:-

    mysql>INSERT INTO table_name (column list) VALUES (column values);

  • SELECT command is used to retrieve data from the tables.

    mysql>SELECT expressions_and_columns FROM table_name
    [WHERE some_condition_is_true]
    [ORDER BY some_column [ASC | DESC]
    [LIMIT offset, rows]


    ORDERBY by column_name can be used with select to display result in specified sorted order.

  • Selecting from a Multiple Tables can be done with the following command:-
    mysql> (select column list) from (table name) where condition;

  • For UPDATING the records is done by:-

    • mysql> update table_name set Column_name = Value;

    • For conditional Updates the syntax is:-

      mysql> update Table_name set column_name where condition;


  • Replacing a RECORD can be done by:-

    mysql> replace into table_name values ();

  • Deleting a record :-
    mysql> DELETE from table_name [where some_condition_is_true][Limit rows]( Meloni , Julie C. 2005," Sams teach yourself PHP,MysQL and Apache all in one", Sams , ed:2.)

  • Length and concatenation function

    • length(), octet_length().char_length(), and character_length() all calculate number of characters in string. syntax is:-

      mysql> select length ('string';


    • To concatenate two string, MySQL have concat() function,
      To concatenate a string with space the function is concat_ws();

    • Trimming and padding
      rtrim() and ltrim() remove the white spaces from the right and left of the string respectively. rpad() and lpad() adds a string to the right and left of the string respectively.

    • To locate a part of string in another string the MySQL has Locate(), syntax is:-

      mysql> select locate( 'string to be find', ' from this string', position from where to start searching);


    • To extract a substring from a target string, mysql has:-
      Substring(), Left() and Right() functions:-


      mysql> select substring("target string", starting position, end position);

      mysql> select left("target string", till this position from left);

      mysql> select right("target string", till this position from right);

    • String modification functions
      For transforming a string into lower and upper case lcase() and ucase() are available:-
      mysql> select lcase('string' or condition)

      mysql> select ucase('string' or condition)

      MySQL have repeat() for repeating a string number of time and replace() from replacing a occurrence of given string from target string.

      mysql> select repeat(" string", number of time);

      mysql> select replace ( ' given string', ' string to be replace',' string with which to replace');









( Meloni , Julie C. 2005," Sams teach yourself PHP,MysQL and Apache all in one", Sams , ed:2.)
(Sheldon, Robert and Moes Geoff 2005,"Beginning MySQL",JohnWiley and sons).

Wednesday, April 22, 2009

How to set Root password for "WAMP"

Hello! Guys,
After installing 'WAMP' last night i face series of problems and today i want to share with you all what you should do if you face the similar problem.

  • Installation of WAMP was successful, but still web browser could not execute php code?

After installing "WAMP" i thought its nice idea to try some php code at home, rather than uploading every php file on uni server and test it. I created a folder inside www folder in C:\Wamp and put my php file in it,as written on www.wampserver.com to my surprise whenever i try to view this page in web browser, the browser did't seem to execute php code but it was showing text written with in HTML elements properly.

The reason for this behavior was my firewall block the php server, so if you guys have firewall installed on you system make your you permit php server. Don't forgot to put WAMP server online , you can do this by left clicking on wamp icon in status bar and selecting option "put online" .


  • Unable to open MySQL console?

Now, i am able to figure out how to execute php code but the problem now is whenever i try to open MySQL console it ask for an password, which i don't have.
so, now i have to set the root password but how to do that?.....
After looking around INTERNET for this. finally i found the answer which involve following steps:-

  • open the phpMyAdmin, you can do this by left clicking on wamp server icon in status bar.
  • click on the privileges tab.
  • Then look for User "root" with host "local host" click on edit privileges( which is on right end of this row).
  • scroll down to change password column and type in password twice and click go.
  • open c:\WAMP\APPS\phpmyadmin3.1.1\config.inc.php in the text editor and search for $cfg['Servers'][$i]['auth_type'] = 'config'; and replace 'config' with 'cookie'.
  • Now look for $cfg['Servers'][$i]['password'] = 'your_password'; and type in your password in between single quotes.
  • its all done...now save this file. exit WAMP server and restart it you would be able to use MySQL console now....


cheers.....

Tuesday, April 21, 2009

Difference between "GET" and "POST"

Technical difference according to HTML specification is, when "GET" is used the form data is encoded(by browser) in to URL whereas in "POST" the data is to appear with in the message body.According to the usage recommendation giving in the specification the "GET" should be used the when the form processing is "idempotent", which mean "GET" is used for the purpose of data retrieving whereas "POST" may be used when service associated with the processing of a form has a side effects like storing or updating data, sending email or ordering products.

Difference in server side processing

As the data is encoded in different way depending on whether it is send by GET or POST, different decoding algorithm is needed which may require some changes in the script that processes the form submission. For example, when using the CGI interface if the method is "GET" the data is received in environmental variable, whereas it is received in standard input when the method is "POST".

Some exceptions were "POST" can be used for idempotent queries

  • Method "GET" is inapplicable if the data present on form is non-Ascii, so using the POST in this case is less dangerous.

  • Method "GET" can not handle long URL so if the from data set is large comprises of hundreds of character, using the POST is advisable.

  • Method "POST" can be used in order to make it less visible to user how the the form queries but its not very effective as it just prevent user from seen the form data in the URL from the user, however user can see the source code of form element.

Saturday, April 18, 2009

History of World Wide Web ( A Report)

In 1980 Tim Berner-lee, while working at CERN(Centre European pour la Recherche Nucleaire -or- European Laboratory for Particle Physics) he acknowledged difficulty to access data simultaneously as the data was stored in different databases on different machines with practically no interaction or connectivity.
He wished to develop a system that would let him quickly and automatically retrieve a mailing address for the receiver of a letter that the might be composing. And he develop a program “Enquire –Within-Upon-Everything” known as Enquire for short, he left CERN soon after the completion of the “Enquire”.

In 1989, He returned back to CERN and witnesses a change in “computing culture” there which revolved around distributed computing and object-oriented programming. Introduction of object oriented technologies by NeXT had made rapid system development and prototyping in a UNIX environment feasible.

In March 1989, He submitted an “ Information Management: A Proposal” highlighting the development of hypertext system that provide a single user-interface to stored information such as reports, notes, data-bases, Computer documentation and online systems help. The proposal’s main objectives were:

• The provision of a simple protocol for requesting human readable information stored in remote systems accessible using networks.
• to provide a protocol by which information could automatically be exchanged in a format common to the information supplier and the information consumer
• the provision of some method of reading text (and possibly graphics) using a large proportion of the display technology in use at CERN at that time
• The provision and maintenance of collections of documents, into which users could place documents of their own.
• To allow documents or collections of documents managed by individuals to be linked by hyperlinks to other documents or collections of documents.
• the provision of a search option, to allow information to be automatically searched for by keywords, in addition to being navigated to by the following of hyperlinks
• To use public domain software wherever possible and to interface to existing proprietary systems.
• To provide the necessary software free of charge.

In 1990, Robert cailliau help Tim to reformulate his proposal and World Wide Web was born as a side effect of the research in particle physics.

reference:
http://ei.cs.vt.edu/~wwwbtb/book/chap1/web_hist.html( link at UTS online Week3:Subject doucment)

Tuesday, March 24, 2009

Week 5- 24/03/09

In this class exercise i just open the source of file week4prac.php in notepad ++ and under the body tag write this code


echo date('l jS \of F Y h:i:s A');
?>

and i got the desired output!.....that was easy

Based on my discussion with Alastair my project is to develop a address book using PHP and MySql any kind of help is welcome guys!

Following is the summary of book which i read in library
Beginning PHP and MySql no voice to professional


Hi Guys! My first introduction to PHP……




Brief history

Rasmus lerdorf developed a perl/CGI script to find out how many visitors were reading his online resume in 1995. Lerdorf then started giving his toolset dubbed Personal Home Page(PHP).
He has been continuously developing language and various version of PHP has been generated.

Some feature of PHP4
- Improved resource handling – this eliminate the drawback of earlier version 3.X of scalability.
- Object oriented support – support a degree of Object oriented paradigm but it was not well structured and implemented.
- Native session-handling support – For earlier version of PHP, Http session handling was available through third party package PHPLIB but PHP 4 has inbuild support for this.
- Encryption – Mcrypt library was included in this to provide encryption facility.
- ISAPI Support – this offered user a way to use PHP with Microsoft’s IIS web server.
- Native Com/DCom Support- ability to access and instantiate window com object
- Native Jave Support- Binding java object through PHP was possible in this version.
- Perl Compatible Regular Expressions(PCRE) library- these are really complex regular Expressions used to carry out complex task. I have seen this in other subject these are scary…..

Some Feature of PHP5
- Enhanced object oriented capabilities - this eliminate the flaws of earlier version.
- Try /catch exception handling- exception handling was added in this version.
- Improved Xml and web service support – Xml known as SimpleXml has been introduced and SOAP extension is now available.
- Native support for Sqlite- SQlite is database sever like MySql and oracle Sql, and support for this was added in PHP5

Some Feature of PHP6

- Unicode support
- Security improvement
- New language feature and structure

As I go through further chapters It remind me of C/C++ which I did during my bachelor’s( those wonder day’s) it pretty much a like but one thing that interest me is PEAR( PHP Extension and application Repository) I am not actually sure what this is at this time? But I can best describe this as a set of ready made function which we can use while scripting which PHP and save us from lot of trouble, but still did’t get how to install these and use this.

- i have downloaded WAMP as been said by Alastair in video lec 4 and looking on the site www.w3schools.com and go through Php commands and MySql

Thats all for today!

Monday, March 23, 2009

Week4 Homework-Application server

Application server can be define as sever program which is a part of n-tier application in a distributed network. It contains the business logic for an application program.
In simple term application sever program act as an interpretor between Web server and database system which contain all the data.Whenever, web server encounter a web page with for example PHP tag in it, it pass it on to the PHP client which decode the tag and deliver the required information to web-server which in turn send that to web browser.

Various application servers
- PHP severs
- various PHP servers are:-
- PHPlens
- PHPappl
- Zend
- Eclipse PHP Development tool kit
- IBM PHP integration kit for Websphere server(Websphere is java appliction server but with PHP integration kit it can also function as PHP application server along with J2ee support.

- J2EE Application server
-various J2EE application servers are:-
- Apache
- Tomcat
- Websphere
- Orion

Friday, March 13, 2009

DMT-Introduction

Hi Guys!
I am chetan wadhwa, i have no previous experience in designing websites although i did HTML i think in 2002 hardly remember it now, i graduated form UTS with my major in Animation in dec'08. Still trying to figuring out what i have to do in this subject DMT but what i really want to do is learn about scripting engine PHP !......

Sunday, February 22, 2009

portfolio

hey guys two year to UTS.............