Saturday, December 19, 2009

ALERT








A
: Attention
L : Life
E : Emergency
R
: Rush up

T : Think about it...!

Friday, 18-Dec-2009, about 9:00 am, in Rimpa Plaza, Karachi, Pakistan.....

There was load shedding our laptops bettry became low so we decide to take tea from outside. But when we came out from our office & go towards stairs some peoples were ran upstairs & said there is fire on 6th floor in a store-room exactly next over our office room. Some of our friends immediately rush up out from the plaza & the other were return to office & shift our laptops to our head office. In th mean time all channels team, police, rescue, ambulance, fire brigade reached & try to stop the fire as soon as possible. Thanks to Allah no one was injered except the 6th floor & the fire became cool after a great efforts. Then after Jumma pray we deside to go back to our home.


Conclusion:
I think that was happened only due to poor security & safty precautions which should be taken by the Plaza owner.
And also office owners must have to choose those place to setup their business where all facilities are available like transport should available for (all) employees & similarly other facilities to face such accidents like on Friday.

Opinion:
In Karachi i think the best location to setup once business is from NIPA to Hassan Square because NIPA is the center to all routs.


Excuse:
There may be some English mistakes so please forgive it.

Thanks.

Friday, November 20, 2009

Create subdomain on localhost in linux

Question: Let suppose i have a web site www.webspot.com. Now I want to create a subdomain sub.domain.com, and when I enter it in my browser, I want to go to the same web site (www.webspot.com).
Answer: Simply on terminal type
  • sudo gedit /etc/apache2/sites-available/your-web-site
file will open now make some little changes like this
ServerName webspot.com

DocumentRoot /var/www/your-website/public
ServerAlias sajid.webspot.com
ServerAlias naveed.webspot.com
ServerAlias nasir.webspot.com
ServerAlias ihsan.webspot.com
ServerAlias zeeshan.webspot.com

Options FollowSymLinks
AllowOverride All

ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined

then type:
  • gedit /etc/hosts
file will open now make some little changes like this
127.0.0.1 localhost

127.0.0.1 webspot.com
127.0.0.1 sajid.webspot.com
127.0.0.1 naveed.webspot.com
127.0.0.1 nasir.webspot.com
127.0.0.1 ihsan.webspot.com
127.0.0.1 zeeshan.webspot.com

127.0.1.1 sajid-laptop

now restart apache2 by using:
  • sudo /etc/init.d/apache2 restart
Enjoy :)

Monday, September 14, 2009

OpenID


OpenID is a standard for user authentication. OpenID allow users to get access to different web services with the same digital identity. By using one OpenID we does not need to create different accounts for different web services.

An OpenID is a unique URL and authenticated by user's OpenID provider. The OpenID protocol does not work on a central authority for user's identity authentication.
OpenID reduce frustration associated with maintaining multiple usernames and passwords and is the safer and easier method to joining new sites.

How to get OpenID:
You may already have an OpenID. If you are using Google, Yahoo, Facebook etc , you does not need to create a new one. OpenID authentication is provided by several large websites. Several organizations either provide or accept OpenIDs, including Google, Facebook, Yahoo!, Microsoft, AOL, MySpace, Sears, etc.

How to login with OpenID?
1. When you visit a site that support OpenID and need authentication, you will see a form like this.
2. Enter your OpenID or your OpenID provider URL (for example yahoo.com) into the form.

3.
Your browser will send you to your OpenID provider login form.

4.
Login to your OpenID provider site with your username and password.

5.
Tell your provider that the original web site can use your identity. You are then sent back to the original website as authenticated user.

Friday, August 21, 2009

Goal Setting

Five Rules to set yourself up for Success

You think about what you want to be doing in your life? Are you clear about what your main objective at work is at moment? Do you know what you want to achieved by the end of today?

If you want to succeed, you need to set goals. Without goals you lack of focus and direction. Goal setting allows you to take control of your life direction and it also provides you a benchmark for determining whether you are actually succeeding.

To achieved your goal, however, you need to know how to set them.

Here are the Five Golden Rules of Goal Setting.

Rule 1: Set Goals that Motivates You.
Rule 2: Set SMART Goals.
Rule3 : Set Goals in Writing.
Rule4 : Make an Action Plan.
Rule5 : stick With it.

Monday, August 17, 2009

Install Mysql on UBUNTU

MySQL Workbench can be easily installed on Ubuntu/Gnome. Just download the binary .deb file from the MySQL web site for workbench (currently named mysql-workbench-oss-5.1.16-1_i386.deb), save it to your home directory. Then run:

sudo apt-get install liblua5.1-0 libzip1
sudo dpkg -i mysql-workbench-oss-5.1.16-1_i386.deb (adapt the name accordingly)
Then, you have MySQL Workbench listed under "Applications > Programming".

Sunday, August 16, 2009




Vertical Bar Graphs with CSS and PHP

Follow this link .....


http://terrill.ca/design/vertical_bar_graphs/#example

Friday, August 7, 2009

Zend Framework on ubuntu





Follow me ....
  • Download Zend Framework (.rar or .tar) from http://framework.zend.com/
  • Un-rar and copy this folder to /var/www/
  • Remove version number from that downloaded folder for example,Zend Framework-1.9.0 to Zend Framework.
  • Goto Terminal type :
  • gedit ~/.profile
An editor will open like below image.
  • Now type the path where you past Zend Framework but must follow the placement of line, see below image.
  • Now save and close this file.
  • Next in Terminal type :
  • gedit /etc/apache2/httpd.conf
An editor will open like below image.
  • Now simply type an ALIAS which you want to reference to your website on localhost, for instance for my website i write " mywebz ", but must follow the format : Alias /mywebz "/var/www/myweb/public"
For more help see below image.
  • Now save and close this file.
  • Atlast to set the above configuration you must restart the apache server.
  • To resatrt apache server, in Terminal type :
  • sudo /etc/init.d/apache2 restart

To test your configuration, in Terminal type :
  • echo $PATH
If you see the path like this:
/var/www/ZendFramework:/var/www/ZendFramework/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
then fine.
  • Now type in Terminal :
  • cd /var/www/web_folder
  • Finally type :
  • zf.sh
A list of Zend Framework eill appear like below image.
Congratulation ... !
You have installed Zend Framework successfully .

Saturday, August 1, 2009

jQuery: Working with Checkboxes

In jQuery sometime you have to work with checkboxes. Find a checkbox by its attributes, Check a checkbox is checked or not and check a checkbox. Their are some related tricks.

Find checkboxes:
$('input[type="checkbox"]') (get all checkboxes)
$('input[name="mycb"]') (get checkbox named mycb)


Get checkboxes Attributes:
$('#myCheckbox').attr('name') (return name of checkbox)
$
('#myCheckbox').attr('checked')
(return true or false)


Checked or Not:
$('#myCheckbox').is(':checked') (return true if checked)


Check/Uncheck a Checkbox:
$('input[name="mycb"]').attr("checked",false); (uncheck named mycb)
$('input[type="checkboxes"]').attr("checked",true); (check all)

Tuesday, July 28, 2009

Creating simple form in Zend Framwork




Zend frame work has a component called zend_form used for creating forms.
It simplify the process of form validation, data filtering, and data storage.
To create a simple form in zend follow the steps:

1- Create a simple form class and place it in application/forms/Simple_Form.
2- Add some element in the Simple_Form class.
3- Create a controller for the Simple_Form using the following command.

(your project path)#zf.sh create controller simple

It will be created in application/controllers/mycontroller.php. It will also create
a folder name 'simple' in application/view/scripts/simple/index.phtml

4- You can also create actions in the controller by using following command.

(your project path)#zf.sh create action myaction simple

After creating an action it would place a file name 'myaction.phtml' in
application/view/scripts/simple/myaction.phtml

Now place an object of your form class in this action.

public function myaction() {

$form = new Simple_Form();
$this->view->form = $form;

}

5- To see the form place the following line in the myaction.phtml file.

$echo $this->form;

Friday, May 29, 2009

Digital Clock using HTML and CSS

following is the code that will display digital clock using java script and CSS class

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Simple Javascript Digital Clock













Wednesday, May 27, 2009

Dynamic PDF files using HTML and PHP


FPDF: The PDF Generator
The first and the main base for this file conversion is FPDF library. FPDF is a pure PHP class to generate PDF files on the fly. Let us start the PDF generation with a simple Hello world display.





require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

To generate a pdf file, first we need to include library file fpdf.php. Then we need to create an FPDF object using the default constructor FPDF(). This constructor can be passed three values namely page orientation (portrait or landscape), measure unit, and page size (A4, A5, etc.,). By default pages are in A4 portrait and the measure unit is millimeter. It could have been specified explicitly with:

$pdf=new FPDF('P','mm','A4');

It is possible to use landscape (L), other page formats (such as Letter and Legal) and measure units (pt, cm, in).

Then we have added a page to our pdf document with AddPage(). The origin is at the upper-left corner and the current position is by default placed at 1 cm from the borders; the margins can be changed with the function SetMargins().

To print a text, we need to first select a font with SetFont(). Let us select Arial bold 16:

$pdf->SetFont('Arial','B',16);

We use Cell() function to output a text. A cell is a rectangular area, possibly framed, which contains some text. It is output at the current position. We specify its dimensions, its text (centered or aligned), if borders should be drawn, and where the current position moves after it (to the right, below or to the beginning of the next line). To add a frame, we would do this:

$pdf->Cell(40,10,'Hello World !',1);

Finally, the document is closed and sent to the browser with Output(). We could have saved it in a file by passing the desired file name.

Thursday, May 21, 2009

Recover a lost Word document


Recover a lost Word document

Describes several methods to locate and to recover a lost Word document file. Provides steps for both Windows Vista and Windows XP.
follow this link.
http://support.microsoft.com/kb/316951

Sunday, May 17, 2009

MySql Teminal Commands

This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality.

Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.
To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p
Create a database on the sql server.

mysql> create database [databasename];
List all databases on the sql server.

mysql> show databases;
Switch to a database.

mysql> use [db name];
To see all the tables in the db.

mysql> show tables;
To see database's field formats.

mysql> describe [table name];
To delete a db.

mysql> drop database [database name];
To delete a table.

mysql> drop table [table name];
Show all data in a table.

mysql> SELECT * FROM [table name];
Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];
Show certain selected rows with the value "whatever".

mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";
Show all records containing the name "ihsan" AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name = "ihsan" AND phone_number = '3444444';
Show all records not containing the name "ihsan" AND the phone number '3444444' order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != "ihsan" AND phone_number = '3444444' order by phone_number;
Show all records starting with the letters 'ihsan' AND the phone number '3444444'.

mysql> SELECT * FROM [table name] WHERE name like "ihsan%" AND phone_number = '3444444';
Show all records starting with the letters 'ihsan' AND the phone number '3444444' limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like "ihsan%" AND phone_number = '3444444' limit 1,5;
Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";
Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];
Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];
Sum column.

mysql> SELECT SUM(*) FROM [table name];
Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password'));
mysql> flush privileges;
Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');
mysql> flush privileges;
Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
Set a root password if there is on root password.

# mysqladmin -u root password newpassword
Update a root password.

# mysqladmin -u root -p oldpassword newpassword
Allow the user "ihsan" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to ihsan@localhost identified by 'passwd';
mysql> flush privileges;
Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

or

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;
To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = 'whatever';
Update database permissions/privilages.

mysql> flush privileges;
Delete a column.

mysql> alter table [table name] drop column [column name];
Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);
Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);
Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);
Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);
Delete unique from table.

mysql> alter table [table name] drop index [colmn name];
Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);
Dump all databases for backup. Backup file is sql commands to recreate all db's.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql
Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));
Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default 'bato');

Thursday, May 14, 2009

You cannot modify the Hosts file or the Lmhosts file in Windows Vista


You cannot modify the Hosts file or the Lmhosts file in Windows Vista

Follow this link
  1. http://support.microsoft.com/kb/923947

Wednesday, May 6, 2009

Usefull Links


Salam to all Muslims & hello to others.
Some times many people become worry and confuse when their Blog posting day come nearer. And the reason of their worried is " what will be the topic of my coming blog . . . . ?".
But i think blog topic is nothing a big issue & we can publish any information related to any field of life.
So today i publish some useful links which i am using & i am sure these will also helpful to you.
PHP links
  1. http://www.daniweb.com/forums/solved17.html
  2. http://www.htmlgoodies.com/beyond/javascript/article.php/3471121
  3. http://www.javascriptkit.com/howto/newtech2.shtml
  4. http://www.phpro.org/tutorials/Creating-A-PHP-Application.html
  5. http://www.tutorialized.com/tutorials/PHP/1
Manul Books
  1. itsstudy8.com
BreadCrumbs
  1. http://www.roscripts.com/PHP_breadcrumbs-118.html
jQuery Link
  1. http://tablesorter.com/docs/
PHP Plugins
  1. http://www.blueshoes.org/en/plugins/
Image Reviewer In PHP
  1. http://www.wellho.net/resources/ex.php4?item=h112/imap.php
Image Maping in PHP
  1. http://www.htmlgoodies.com/tutorials/image_maps/article.php/3479741
Image Galler
  1. http://www.lateralcode.com/2009/03/create-a-simple-picture-gallery-using-php/
  2. http://www.ricocheting.com/scripts/gallery.html
MySql Book
  1. http://www.php.net/mysql_field_name
Pear Log
  1. http://pear.php.net/package/Log/docs/1.11.4/Log/Log_error_log.html
PHP Classes
  1. http://www.phpclasses.org/browse/package/3165.html

Friday, May 1, 2009

XML-based RSS parser in PHP

MagpieRSS provides an XML-based RSS parser in PHP.

Link:
http://magpierss.sourceforge.net/

Download:
http://sourceforge.net/project/showfiles.php?group_id=55691


How to Use:
- Download magpierss-version.tar.gz file
- Extract downloaded file.
- include magpierss-version/rss_fetch.inc file in your php file.

require('rss_fetch.inc');
$rss = fetch_rss($url);

- ready to parse RSS



A Simple Example:

require_once 'rss_fetch.inc';

$url = 'http://www.example.com/rss/today.xml';
$rss = fetch_rss($url);

echo "Site: ", $rss->channel['title'];

foreach ($rss->items as $item ) {
$title = $item[title];
$url = $item[link];
echo $title . "," . $url ;
}

Friday, April 24, 2009

Problems In Smarty Template

some times i found a problem in smarty template that whenever i do some changes in my template coding and refresh html page the changes do not applied.i was wondering what is the problem in it.after having so much research i found that smarty creates obj templates every time you do some changes in template.
then i delete all obj templates and then refresh the page.the changes are now applied in the page

Preg_Match PHP Function













The
Preg_Match PHP function is used to search a string, and return a 1 or 0. If the search was successful a 1 will be returned, and if it was not found a 0 will be returned. Although other variables can be added, it is most simply phrased as: preg_match(search_pattern, your_string).

There are two scripts which validates the format of a url text string and domain. It might be used to check the url submitted from a form. The format of the url is expected to be of the form: domain-name.co.uk for example.

  • First script validates a url. This make use of regular expression pattern matching.



//url validation

$url = 'teSTgjhgj.co.uk';

if (preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i", $url)) {

print "$url url OK.";

} else {

print "$url url not valid!";

}

?>
  
  • Second script validates a domain.
  


//domain validation

$domain = 'teSTgjhgj';

if (preg_match ("/^[a-z0-9][a-z0-9\-]+[a-z0-9]$/i", $domain)) {

print "$domain Domain OK.";

} else {

print "$domain Domain not valid!";

}

?>

Wednesday, April 22, 2009

Digital Clock in PHP


This is a PHP script for displaying the current time in a digital clock on your web page. It uses individual digit images for the clock, and does not require any special library.

You can download the zip format of code file from
http://www.hotscripts.com/listing/digital-clock-6741/

Monday, April 20, 2009

Change Mysql root password

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password:

# mysqld_safe --skip-grant-tables &
Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client:

# mysql -u root
Output:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop
Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe --skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p

Installing Skype on Ubunto

If you’re interested in running Skype on Ubuntu then follow these steps.

From the Ubuntu System menu select:
Administration –> Synaptic Package Manager

synaptic.png

Inside Synaptic Package Manager select the Tools –> Repositories menu option. Make sure all the checkboxes are checked. Then close the Synaptic Package Manager.

screenshot-software-sources.png

Next you need to add the Medibuntu repository. Full details about this repository, including installation instructions, can be found on the Medibuntu home page.

To install Medibuntu you need to run a Terminal window session. From the Ubuntu Applications –> Accessories menu select Terminal

ubuntu-terminal.png

Assuming you’re running Ubuntu 7.04 Feisty Fawn you need to enter the following into a command window. If you’re using an earlier version of Ubuntu then refer to the Medibuntu home page for installation instructions.

sudo wget http://www.medibuntu.org/sources.list.d/feisty.list -O /etc/apt/sources.list.d/medibuntu.list

wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - && sudo apt-get update

sudo aptitude install skype

That’s it!

Skype should now be available from the Applications –> Internet menu.

skype.png

Saturday, April 11, 2009

HTML DOM Parsing

If you want to extract data from a webpage and not getting the exact data using different patterns and "PHP String Positions" techniques, then here is the suggestion for you.

This is Simple HTML DOM Parser written in PHP5+ by a Developer on Sourceforge.net

Developer Profile:
http://sourceforge.net/users/me578022/

Download Link:
http://sourceforge.net/projects/simplehtmldom/

Documentions:
http://simplehtmldom.sourceforge.net/



How to Use:

First of all download the simple_html_dom.php File from download link.


// Include the downloded file in your own php file.
include('../simple_html_dom.php');

// Create a DOM First:
$html = file_get_html('http://www.google.com/'); // Create DOM from URL or file
$html = str_get_html($str, $lowercase=true); // Create DOM from String of HTML Script


// find all links
foreach($html->find('a') as $element)
echo $element->href;

// find all images
foreach($html->find('img') as $element)
echo $element->src;

// find all images with full tag
foreach($html->find('img') as $element)
echo $element->outertext;

// find all div tags with id=gbar
foreach($html->find('div#gbar') as $element)
echo $element->innertext;

// find all span tags with class=gb1
foreach($html->find('span.gb1') as $element)
echo $element->outertext;

// find all td tags with attribite align=center
foreach($html->find('td[align=center]') as $element)
echo $element->innertext;

// extract text from table
echo $html->find('td[align="center"]', 1)->plaintext;

// extract text from HTML
echo $html->plaintext;



Read documents for more example.

Friday, April 10, 2009

Installation Problem in UBUNTU





After installing Ubuntu, i was installing system application
jre-1_6_0_02-linux-i586-rpm.bin. Every thing was going right
suddenly a message of service agreement appeared and the
installation was stopped. I closed the terminal and tried to reinstall
the application. Then i received the message,

"E: dpkg was interrupted, you must manually run
'dpkg --configure -a' to correct the problem."

I couldn't install anything through my terminal or my synaptic manager.
Then i found the solution of this problem.

Solution:

On terminal, execute the following commands:

sudo dpkg --configure -a
sudo dpkg --update -a


Thursday, April 9, 2009

Accedently Replace / Remove Directory From SVN

Problem
I have replace a directory from 'trunk' at revision 977 & now i want to rollback to revision 974 .....!

Solution
Simply follow these steps mentioned below:
1- $ svn merge -r 977:974 https://som_one.com/repos/home/trunk
2- $ svn commit -m "Recover Lost Directory"
3- $ svn update

Tuesday, April 7, 2009

SOAP

Introduction:

SOAP is an XML-based messaging protocol. It defines a set of rules for structuring messages that can be used for simple one-way messaging but is particularly useful for performing RPC-style (Remote Procedure Call) request-response dialogues. It is not tied to any particular transport protocol though HTTP is popular. Nor is it tied to any particular operating system or programming language so theoretically the clients and servers in these dialogues can be running on any platform and written in any language as long as they can formulate and understand SOAP messages. As such it is an important building block for developing distributed applications that exploit functionality published as services over an intranet or the internet.

Server Side:

As is the case with any client-server paradigm, in the world of web services there are web service providers and web service consumers. Server-Side SOAP is a tutorial which deals with how to build and provide web services using Apache SOAP. We will cover the details of the technology for consuming web services when we work through SOAP on the Client-Side.

Client Side:

Client-Side SOAP is a multi-part tutorial with the aim of introducing you to some of the technologies available for writing clients that consume web services using SOAP.

For detail information:
Follow the link http://www.soapuser.com/index.html

Document Comparisons


Compare Files with 'Diff Doc'
(The Comprehensive Document Comparison Tool)
Some times more than one person( lets, you & your partner ) are working on the same file that may on ( MS Word/Excel/PowerPoint, PDF, RTF, Text, HTML, XML, Wordperfect ), and suppose you need to check the modifications that have been made by your partner then either you'll request him to inform you about those changes made by him or review the whole file to justify the changes, but it may takes more time & may be you could not correctly justify .

I was also passed through that experience & i faced much problems, so i thought that their must be utility tools to solve such problems & at last i found an excellent
utility tool " Diff Doc ", but its a trial version. Following are its features i have test it is really a nice one ....

Diff Doc Features
  • Compare documents of MS Word (DOC, DOCX etc), Excel, PDF, Rich Text (RTF), Text, HTML, XML, PowerPoint, or Wordperfect and retain formatting
  • Choose any portion of any document (file) and compare it against any portion of the same or different document (file).
  • Word to word or letter to letter comparisons. See to the letter what changed in a sentence.
  • Compare files of any type against any file type (i.e. An MS Word compared against a. Wordperfect document)
  • Integrated into the Windows Explorer Shell (Windows Explorer, Desktop, Find in Files, etc.) for quick comparisons
  • Navigate easily through the file differences with the Next (F7), Previous (Shift+F7) etc. navigation buttons. Or use the drop down list box to jump to a specific difference
  • Paragraph differences are highly detailed
  • Compares text from any application by cutting and pasting into 'Diff Doc'.
  • Both 'Side By Side' and the red-lined 'All In One' difference views are supported
  • Save any of the views as DOC, Text, RTF or HTML format
  • Text and Comma Delimited reports also available
  • Compare folders first, then quickly see what files are different and compare with a mouse click
  • Compatible with WORLDOX, and any other document management software that supports 3rd party file comparison applications through the command line. Click here for details
  • Run it from the Command Line or build your own solutions by using the ActiveX COM interface (available upon request)
Download Link for Diff Doc
http://www.softinterface.com/DL/DL_UserData_Proc.ASP


Thursday, March 26, 2009

Pagination in PHP

Pagination in PHP




Step One

  1. Connect to MySQL database.
For those who are new to PHP & MySQL and do not know how to establish connection with MySQL, may use the following config.php.file code.

//Host name

$host='localhost';

//User name

$user='root';

//Password

$pass='';

//Database name

$db='mydb';

//Establishing database connection

mysql_connect($host,$user,$pass);

//Select database

mysql_select_db($db) or die ("Database Connection Failed") ;

?>


Step Two
  1. Set Variables:
  2. Set table name you want to use (Table must contain an auto increment field named “Id”).
  3. Set the column name you want to show.
  4. Set number of rows per page (default is 5 rows/page).
After configure variables as defined above, simply run the script and enjoy {:-Þ

//Include config file

includes('config.php');

//Table name

$myTable='Mytable';

//Column Name

$columnName='Columnname';

//How many rows to show per pg

$rowsperpg=5;

//by default we show first pg

$pgnum=1;

//if $_GET['page'] defined, use it as first page number

if(isset($_GET['page']))

{

$pgnum=$_GET['page'];

}

//counting the offset

$offset=($pgnum-1)*$rowsperpg;

$test="SELECT * FROM '".$myTable."' LIMIT $offset,$rowsperpg";

$run=mysql_query($test) or die('selection fail');

//print

$count=mysql_num_rows($run);

if($count > 0)

{

while($res=mysql_fetch_assoc($run))

{

echo '

';

echo '

';

echo '

Event: '.$res[$columnName].'
';

echo '
'
;

}

//how many rows we have in db

$query="SELECT COUNT(Id) as numrows FROM '".$myTable."' ";

$res=mysql_query($query) or die('Error Query failed');

$row=mysql_fetch_assoc($res);

$numrows=$row['numrows'];

//how many pg we have when using paging?

$maxpg=ceil($numrows/$rowsperpg);

// print the link

$self=$_SERVER['PHP_SELF'];

$nav='';

for($page=1;$page<=$maxpg;$page++)

{

if($page==$pgnum)

{

$nav.="$page";

}

else

{

$nav.="$self?page=$page\">$page";

}

}

if($pgnum>1)

{

$page=$pgnum-1;

$prev="$self?page=$page\">[Prev]";

$first="$self?page=1\">[First Page]";

}

else

{

$prev=' ';

$first=' ';

}

if($pgnum<$maxpg)

{

$page=$pgnum+1;

$next="$self?page=$page\">[Next]";

$last="$self?page=$maxpg\">[Last Page]";

}

else

{

$next=' ';

$last=' ';

}

echo '

'.$first.' '.$prev.' '.'page'. $pgnum.' '.' of'.' '.$maxpg.' '.$next.' '.$last.'
';

}

if($count <= 0)

{

?>

<div style="color: #FF3300" align="center">

<p><h5>No Record Availableh5>p>

div>

}

?>