Tuesday, February 13, 2007

How to recover a website from the cache of Google, Internet Archive, Yahoo, MSN

I tried to change several websites by code.I meant to change some pages automatically for they had the same problem.But when the program finished to do so, it was not the result I expected. All the PHP files on the sever were changed to size 0.It's a bad day...Maybe it's something wrong with the server.I just called the server company and asked if they can recover all these size 0 files.They told me it's impposble, they did not have back-ups.What a bad day...bad severice...What should I do?I just thought something about google cache.All of these websites were indexed by Google, Internet Archive, Yahoo, MSN.Can I recover them from these caches?Really a good idea.But how to?I know it's possible to visit all the caches and download the cache files manually.But it's really a large project.I don't want to do this.Maybe I am very lazy.So I go to google for more information.Suddenly Google take me to Warrick, my savior, it's a perl program which is writen by Frank McCown. Soonly I learned how to use it and went to recover my site.The program is very powerful, but the recovery time may be a little long, but it's OK.Really Thanks Frank McCown, thanks very much for good research...

Have you met the same problem with me?Hope it will help you...Good Luck...

Monday, February 12, 2007

Choosing a page encoding

Choosing a page encoding Choose UTF-8 or another Unicode encoding for all content.

When selecting a page encoding, consider both current and future localization requirements, and the benefits of using the same encoding across all pages and all languages. These considerations make the use of Unicode an attractive choice for the following reasons:

Unicode supports many languages, enabling the use of a single encoding across all pages and forms, regardless of language.

Unicode allows many more languages to be mixed on a single page than almost any other choice. If the set of languages to be represented on a single page cannot be represented directly by any single native encoding (such as ISO-8859-1, Shift-JIS, etc.), then Unicode is almost certainly the best choice.

For dynamically-generated pages, a single encoding for all pages eliminates the need for server-side logic to determine the character encoding for each page served.

For interactive applications using forms, a single encoding eliminates the need for server-side logic to determine the character encoding of incoming form data.

Unicode enables a form in one language (e.g. English) to accept input in a different language (e.g. Chinese).

Unicode (UTF-8) forms will be easier to migrate to XForms.

UTF-8 and UTF-16 are both Unicode encodings. Since support for Unicode is currently limited to UTF-8 in many user agents, UTF-8 is usually the appropriate Unicode encoding. However, as user agent support for UTF-16 expands, UTF-16 will become an increasingly viable alternative.

Although there are other multi-script encodings (such as ISO-2022 and GB18030), Unicode generally provides the best combination of user agent and script support.

If you don't use a Unicode encoding, select an encoding that best supports the languages / characters to be included in the page text.

There are some situations where selecting a Unicode encoding is not practical. If content is encoded in a native encoding (legacy content or content originating from an external source) and the system lacks functionality for converting content between encodings, Unicode may greatly complicate implementation. If such a site is only required to serve single-script pages (containing languages that can be represented by a single native encoding), then the cost of using a Unicode encoding may outweigh the benefits. In this case, a native encoding (such as ISO-8859-1, Shift-JIS, etc.) may be a better choice.

Be sure to select an encoding that covers most of the characters required for the content, and (if it is a form) all of the characters that must be accepted as input.

Check that user agents (all agents that must render the page) adequately support the page encoding that you have selected. If not, you might need to use a more widely supported encoding to achieve an adequate degree of user agent support.

Not all user agents support all page encodings, so it is important to understand which user agents must be able to render the page, and be sure that they have adequate support for the page encoding you have selected.

In general, user agents are most likely to support the commonly-used native character encodings for the major languages used on the web. Support for less commonly used encodings depends on the user agent. Older user agents, or user agents that operate under severe memory limitations, may not support UTF-8.

It is important to note that support for a given encoding does not necessarily imply support for all writing systems that encoding supports. For example, a user agent might support UTF-8, but not correctly display bidirectional Arabic text encoded in UTF-8. To display a page correctly, a user agents must support both the page encoding and the writing system.

Saturday, February 10, 2007

Notes for learing SQL(3)

14. The SELECT INTO Statement

The SELECT INTO statement is most often used to create backup copies of tables or for archiving records.

15. SQL CREATE VIEW Statement

A view is a virtual table based on the result-set of a SELECT statement.
What is a View?In SQL, a VIEW is a virtual table based on the result-set of a SELECT statement.

A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from a single table.

Note: The database design and structure will NOT be affected by the functions, where, or join statements in a view.

Very hard to understand these two, need to learn more and do more exercises...

Friday, February 09, 2007

Notes for learing SQL(2)

9. Create Index

Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes, they are just used to speed up queries.

Note: Updating a table containing indexes takes more time than updating a table without, this is because the indexes also need an update. So, it is a good idea to create indexes only on columns that are often used for a search.

CREATE INDEX index_nameON table_name (column_name)

10. Truncate a Table

What if we only want to get rid of the data inside a table, and not the table itself? Use the TRUNCATE TABLE command (deletes only the data inside the table):

TRUNCATE TABLE table_name

11. ALTER TABLE

The ALTER TABLE statement is used to add or drop columns in an existing table.

ALTER TABLE table_name ADD column_name datatype
ALTER TABLE table_name DROP COLUMN column_name

Note: Some database systems don't allow the dropping of a column in a database table (DROP COLUMN column_name).

12. SQL Functions

SQL has a lot of built-in functions for counting and calculations.
Function SyntaxThe syntax for built-in SQL functions is:

SELECT function(column) FROM table

Types of Functions

There are several basic types and categories of functions in SQL. The basic types of functions are:

Aggregate Functions - Aggregate functions operate against a collection of values, but return a single value.

Scalar functions - Scalar functions operate against a single value, and return a single value based on the input value.

13. SQL GROUP BY and HAVING

GROUP BY...GROUP BY... was added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called, and without the GROUP BY function it was impossible to find the sum for each individual group of column values.

The syntax for the GROUP BY function is:

SELECT column,SUM(column) FROM table GROUP BY column

HAVING...HAVING... was added to SQL because the WHERE keyword could not be used against aggregate functions (like SUM), and without HAVING... it would be impossible to test for result conditions.

The syntax for the HAVING function is:

SELECT column,SUM(column) FROM tableGROUP BY columnHAVING SUM(column) condition value

Thursday, February 08, 2007

Notes for learing SQL(1)

1. Some Abbreviations

SQL - Sturcture Query Language

DML - Data Manipulation Language (Part of SQL)

SELECT - extracts data from a database table
UPDATE - updates data in a database table
DELETE - deletes data from a database table
INSERT INTO - inserts new data into a database table

DDL - Data Definition Language (Part of SQL)

CREATE TABLE - creates a new database table
ALTER TABLE - alters (changes) a database table
DROP TABLE - deletes a database table
CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index

2. Using Quotes

SQL uses single quotes around text values (most database systems will also accept double quotes). Numeric values should not be enclosed in quotes.

3. The LIKE condition

A "%" sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern.

SELECT * FROM Persons WHERE FirstName LIKE 'O%'
//return persons with first names that start with an 'O'

SELECT * FROM Persons WHERE FirstName LIKE '%a'
//return persons with first names that end with an 'a'

SELECT * FROM Persons WHERE FirstName LIKE '%la%'
//return persons with first names that contain the pattern 'la'

4. IN

The IN operator may be used if you know the exact value you want to return for at least one of the columns.

SELECT column_name
FROM table_name
WHERE column_name IN (value1,value2,..)

5. BETWEEN ... AND

The BETWEEN ... AND operator selects a range of data between two values. These values can be numbers, text, or dates.

SELECT column_name
FROM table_name
WHERE column_name BETWEEN value1 AND value2

To display values outside the range, use the NOT operator:

SELECT column_name FROM table_name WHERE column_name NOT BETWEEN value1 AND value2

IMPORTANT! The BETWEEN...AND operator is treated differently in different databases.Whether the return set include or exclude value1 or value2, you need to check your database.

6. SQL alias

With SQL, aliases can be used for column names and table names.

SELECT column AS column_alias FROM table SELECT column FROM table AS table_alias

7. SQL JOIN

INNER JOIN

SELECT field1, field2, field3
FROM first_table
INNER JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield

The INNER JOIN returns all rows from both tables where there is a match. If there are rows in first_table that do not have matches in second_table, those rows will not be listed.

LEFT JOIN

SELECT field1, field2, field3
FROM first_table
LEFT JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield

The LEFT JOIN returns all the rows from the first_table, even if there are no matches in the second_table. If there are rows in first_table that do not have matches in second_table, those rows also will be listed.

RIGHT JOIN

SELECT field1, field2, field3
FROM first_table
RIGHT JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield

The RIGHT JOIN returns all the rows from the second_table, even if there are no matches in the first_table. If there had been any rows in second_table that did not have matches in first_table, those rows also would have been listed

8. SQL UNION and UNION ALL

SQL Statement 1
UNION
SQL Statement 2

The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type.
Note: With UNION, only distinct values are selected.

SQL Statement 1
UNION ALL
SQL Statement 2

The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values(include the same values).

Tuesday, February 06, 2007

About FULLTEXT

I am learning "Beginning PHP5 Apache and MySQL Web Development" now.It's really a good book for PHP beginners.If you are just start now, I strongly recommend you to read this book.Very easy to understand, so many examples...www.wrox.com

I am reading chapter 16 - a bulletin board.While I am trying to run the setup.php, a problem jump out... "The used table type doesn't support FULLTEXT indexes".This is the first time I meet this kind MySQL problem.I searched on Google and got the answer.

"This message appears when the database server is configured to use another table type than MyISAM."

original code -
CREATE TABLE forum_posts (
id int(11) NOT NULL auto_increment,
topic_id int(11) NOT NULL default '0',
forum_id int(11) NOT NULL default '0',
author_id int(11) NOT NULL default '0',
update_id int(11) NOT NULL default '0',
date_posted datetime NOT NULL default '0000-00-00 00:00:00',
date_updated datetime NOT NULL default '0000-00-00 00:00:00',
subject varchar(255) NOT NULL default '',
body mediumtext NOT NULL,
PRIMARY KEY (id),
KEY IdxArticle (forum_id,topic_id,author_id,date_posted),
FULLTEXT KEY IdxText (subject,body)
) TYPE=MyISAM //add the red code to correct the mistake.

If you meet the same problem, hope the article can help you.

Monday, February 05, 2007

Something about PHP File Upload

Today, I learned something about PHP File Upload and found a good place to study.

http://www.w3schools.com/

Saturday, February 03, 2007

Some suggestion to learn PHP and truely understand it

Today I read 2 artcles, found them were very useful for those who are learning and using PHP.Please do not satisfy with what you have learned.Always keep on learning...

1. How to Learn PHP (and Understand It)
I don’t think there’s a day that goes by that I don’t see someone just coming into the world of PHP, eyes bright with promise and hope, ready to tackle just about anything that comes their way. Of course, reality sinks in and, unless they’re already pretty well versed with programming and the thought processes that go on behind it, they might take one look at PHP and run screaming...

2. Just PHP will give you nothing… unless you upgrade yourself
I have been working with PHP for more than 3yrs (I believe still I am beginner in this category) - I was present in several interview board. Which things disappointed me most is the “lack of eagerness” to learn what comes new. Sometime developers thinks that learning Only PHP will help them to get lucrative jobs...

I am a beginner to PHP...So I think I have to start some small projects and do some freelance jobs.Only in this way can enhance my programming level.Practice makes perfect, the more you practice the better you get.Always keep on learning and practising...

Friday, February 02, 2007

My first Post on my blog...

I got this blog on Oct 6th, 2006.Just came and have a look for google's new product.I found it was funny and post a test page.But at this time,I really decide to write something.

For my first post.I want to introduce some websites I often use.May be useful for you too.

1. www.getafreelancer.com - A very useful site to find a PHP freelance job.Also other programming language jobs..."Become a freelance programmer, web designer, copywriter or translator and let us help you find customers from all over the world! It's free to sign up. Join us and start making money Today!"

2. www.statcounter.com - A free yet reliable invisible web tracker, highly configurable hit counter and real-time detailed web stats. Insert a simple piece of their code on your web page and you will be able to analyse and monitor all the visitors to your website in real-time! Free to use 100 logs,need pay for more...But I think it's enough for personal use.

3. www.fromshawn.com - Some free SEO sofeware..."Who Else Is Sick Of The SEO Hype??? Want Some FREE SEO Tools That Are Better Than The Paid Ones??? Here Ya Go..."

Hope all of these information are useful for you...