Thursday, July 2, 2009

PHP Math Introduction

The math functions can handle values within the range of integer and float types.


Installation

The math functions are part of the PHP core. There is no installation needed to use these functions.

PHP Math Constants

PHP: indicates the earliest version of PHP that supports the constant.

Constant Description PHP
M_E Returns e (approx. 2.718) 4
M_EULER Returns Euler's constant (approx. 0.577) 4
M_LNPI Returns the natural logarithm of PI (approx. 1.144) 4
M_LN2 Returns the natural logarithm of 2 (approx. 0.693) 4
M_LN10 Returns the natural logarithm of 10 (approx. 2.302) 4
M_LOG2E Returns the base-2 logarithm of E (approx. 1.442) 4
M_LOG10E Returns the base-10 logarithm of E (approx. 0.434) 4
M_PI Returns PI (approx. 3.14159) 3
M_PI_2 Returns PI/2 (approx. 1.570) 4
M_PI_4 Returns PI/4 (approx. 0.785) 4
M_1_PI Returns 1/PI (approx. 0.318) 4
M_2_PI Returns 2/PI (approx. 0.636) 4
M_SQRTPI Returns the square root of PI (approx. 1.772) 4
M_2_SQRTPI Returns 2/square root of PI (approx. 1.128) 4
M_SQRT1_2 Returns the square root of 1/2 (approx. 0.707) 4
M_SQRT2 Returns the square root of 2 (approx. 1.414) 4
M_SQRT3 Returns the square root of 3 (approx. 1.732) 4

Wednesday, July 1, 2009

PHP MySQL Introduction

The MySQL functions allows you to access MySQL database servers.
Installation
For the MySQL functions to be available, you must compile PHP with MySQL support.
For compiling, use --with-mysql=DIR (the optional DIR points to the MySQL directory).
Note: For full functionality of MySQL versions greater than 4.1., use the MySQLi extension instead. If you would like to install both the mysql extension and the mysqli extension you should use the same client library to avoid any conflicts.
Installation on Linux Systems
PHP 5+: MySQL and the MySQL library is not enabled by default. Use the --with-mysql=DIR configure option to include MySQL support and download headers and libraries from mysql.com.
Installation on Windows Systems
PHP 5+: MySQL is not enabled by default, so the php_mysql.dll must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution, and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH.
To enable any PHP extension, the PHP extension_dir setting (in the php.ini file) should be set to the directory where the PHP extensions are located. An example extension_dir value is c:\php\ext.
Note: If you get the following error when starting the web server: "Unable to load dynamic library './php_mysql.dll'", this is because php_mysql.dll or libmysql.dll cannot be found by the system.
Runtime Configuration
The behavior of the MySQL functions is affected by settings in the php.ini file.
MySQL configuration options:
Name Default Description Changeable
mysql.allow_persistent
"1"
Whether or not to allow persistent connections
PHP_INI_SYSTEM
mysql.max_persistent
"-1"
The maximum number of persistent connections per process
PHP_INI_SYSTEM
mysql.max_links
"-1"
The maximum number of connections per process (persistent connections included)
PHP_INI_SYSTEM
mysql.trace_mode
"0"
Trace mode. When set to "1", warnings and SQL-errors will be displayed. Available since PHP 4.3
PHP_INI_ALL
mysql.default_port
NULL
The default TCP port number to use
PHP_INI_ALL
mysql.default_socket
NULL
The default socket name to use. Available since PHP 4.0.1
PHP_INI_ALL
mysql.default_host
NULL
The default server host to use (doesn't apply in SQL safe mode)
PHP_INI_ALL
mysql.default_user
NULL
The default user name to use (doesn't apply in SQL safe mode)
PHP_INI_ALL
mysql.default_password
NULL
The default password to use (doesn't apply in SQL safe mode)
PHP_INI_ALL
mysql.connect_timeout
"60"
Connection timeout in seconds
PHP_INI_ALL
Resource Types
There are two resource types used in the MySQL extension. The first one is the link_identifier for a database connection, the second is a resource which holds the result of a query.
Note: Most MySQL functions accept link_identifier as the last optional parameter. If it is not provided, the last opened connection is used.
PHP MySQL Functions
PHP:
indicates the earliest version of PHP that supports the function.
Function Description PHP
mysql_affected_rows()
Returns the number of affected rows in the previous MySQL operation
3
mysql_change_user()
Deprecated. Changes the user of the current MySQL connection
3
mysql_client_encoding()
Returns the name of the character set for the current connection
4
mysql_close()
Closes a non-persistent MySQL connection
3
mysql_connect()
Opens a non-persistent MySQL connection
3
mysql_create_db()
Deprecated. Creates a new MySQL database. Use mysql_query() instead
3
mysql_data_seek()
Moves the record pointer
3
mysql_db_name()
Returns a database name from a call to mysql_list_dbs()
3
mysql_db_query()
Deprecated. Sends a MySQL query. Use mysql_select_db() and mysql_query() instead
3
mysql_drop_db()
Deprecated. Deletes a MySQL database. Use mysql_query() instead
3
mysql_errno()
Returns the error number of the last MySQL operation
3
mysql_error()
Returns the error description of the last MySQL operation
3
mysql_escape_string(
Deprecated. Escapes a string for use in a mysql_query. Use mysql_real_escape_string() instead
4
mysql_fetch_array()
Returns a row from a recordset as an associative array and/or a numeric array
3
mysql_fetch_assoc()
Returns a row from a recordset as an associative array
4
mysql_fetch_field()
Returns column info from a recordset as an object
3
mysql_fetch_lengths()
Returns the length of the contents of each field in a result row
3
mysql_fetch_object()
Returns a row from a recordset as an object
3
mysql_fetch_row()
Returns a row from a recordset as a numeric array
3
mysql_field_flags()
Returns the flags associated with a field in a recordset
3
mysql_field_len()
Returns the maximum length of a field in a recordset
3
mysql_field_name()
Returns the name of a field in a recordset
3
mysql_field_seek()
Moves the result pointer to a specified field
3
mysql_field_table()
Returns the name of the table the specified field is in
3
mysql_field_type()
Returns the type of a field in a recordset
3
mysql_free_result()
Free result memory
3
mysql_get_client_info()
Returns MySQL client info
4
mysql_get_host_info()
Returns MySQL host info
4
mysql_get_proto_info()
Returns MySQL protocol info
4
mysql_get_server_info()
Returns MySQL server info
4
mysql_info()
Returns information about the last query
4
mysql_insert_id()
Returns the AUTO_INCREMENT ID generated from the previous INSERT operation
3
mysql_list_dbs()
Lists available databases on a MySQL server
3
mysql_list_fields()
Deprecated. Lists MySQL table fields. Use mysql_query() instead
3
mysql_list_processes()
Lists MySQL processes
4
mysql_list_tables()
Deprecated. Lists tables in a MySQL database. Use mysql_query() instead
3
mysql_num_fields()
Returns the number of fields in a recordset
3
mysql_num_rows()
Returns the number of rows in a recordset
3
mysql_pconnect()
Opens a persistent MySQL connection
3
mysql_ping()
Pings a server connection or reconnects if there is no connection
4
mysql_query()
Executes a query on a MySQL database
3
mysql_real_escape_string()
Escapes a string for use in SQL statements
4
mysql_result()
Returns the value of a field in a recordset
3
mysql_select_db()
Sets the active MySQL database
3
mysql_stat()
Returns the current system status of the MySQL server
4
mysql_tablename()
Deprecated. Returns the table name of field. Use mysql_query() instead
3
mysql_thread_id()
Returns the current thread ID
4
mysql_unbuffered_query()
Executes a query on a MySQL database (without fetching / buffering the result)
4
PHP MySQL Constants
Since PHP 4.3 it has been possible to specify additional flags for the mysql_connect() and mysql_pconnect() functions:
PHP: indicates the earliest version of PHP that supports the constant.
Constant Description PHP
MYSQL_CLIENT_COMPRESS
Use compression protocol
4.3
MYSQL_CLIENT_IGNORE_SPACE
Allow space after function names
4.3
MYSQL_CLIENT_INTERACTIVE
Allow interactive timeout seconds of inactivity before closing the connection
4.3
MYSQL_CLIENT_SSL
Use SSL encryption (only available with version 4+ of the MySQL client library)
4.3
The mysql_fetch_array() function uses a constant for the different types of result arrays. The following constants are defined:
Constant Description PHP
MYSQL_ASSOC
Columns are returned into the array with the fieldname as the array index

MYSQL_BOTH
Columns are returned into the array having both a numerical index and the fieldname as the array index

MYSQL_NUM
Columns are returned into the array having a numerical index (index starts at 0)

PHP SimpleXML Introduction

The SimpleXML functions lets you convert XML to an object.
This object can be processed, like any other object, with normal property selectors and array iterators.
Some of these functions requires the newest PHP build.
Installation
The SimpleXML functions are part of the PHP core. There is no installation needed to use these functions.
PHP SimpleXML Functions
PHP: indicates the earliest version of PHP that supports the function.
Function Description PHP
construct()
Creates a new SimpleXMLElement object
5
addAttribute()
Adds an attribute to the SimpleXML element
5
addChild()
Adds a child element the SimpleXML element
5
asXML()
Gets an XML string from a SimpleXML element
5
attributes()
Gets a SimpleXML element's attributes
5
children()
Gets the children of a specified node
5
getDocNamespaces()
Gets the namespaces of an XML document
5
getName()
Gets the name of a SimpleXML element
5
getNamespaces()
Gets the namespaces from XML data
5
registerXPathNamespace()
Creates a namespace context for the next XPath query
5
simplexml_import_dom()
Gets a SimpleXMLElement object from a DOM node
5
simplexml_load_file()
Gets a SimpleXMLElement object from an XML document
5
simplexml_load_string()
Gets a SimpleXMLElement object from an XML string
5
xpath()
Runs an XPath query on XML data
5

PHP String Introduction

The string functions allow you to manipulate strings.
Installation
The string functions are part of the PHP core. There is no installation needed to use these functions.
PHP String Functions
PHP: indicates the earliest version of PHP that supports the function.
Function Description PHP
addcslashes()
Returns a string with backslashes in front of the specified characters
4
addslashes()
Returns a string with backslashes in front of predefined characters
3
bin2hex()
Converts a string of ASCII characters to hexadecimal values
3
chop()
Alias of rtrim()
3
chr()
Returns a character from a specified ASCII value
3
chunk_split()
Splits a string into a series of smaller parts
3
convert_cyr_string()
Converts a string from one Cyrillic character-set to another
3
convert_uudecode()
Decodes a uuencoded string
5
convert_uuencode()
Encodes a string using the uuencode algorithm
5
count_chars()
Returns how many times an ASCII character occurs within a string and returns the information
4
crc32()
Calculates a 32-bit CRC for a string
4
crypt()
One-way string encryption (hashing)
3
echo()
Outputs strings
3
explode()
Breaks a string into an array
3
fprintf()
Writes a formatted string to a specified output stream
5
get_html_translation_table()
Returns the translation table used by htmlspecialchars() and htmlentities()
4
hebrev()
Converts Hebrew text to visual text
3
hebrevc()
Converts Hebrew text to visual text and new lines (\n) into

3
html_entity_decode()
Converts HTML entities to characters
4
htmlentities()
Converts characters to HTML entities
3
htmlspecialchars_decode()
Converts some predefined HTML entities to characters
5
htmlspecialchars()
Converts some predefined characters to HTML entities
3
implode()
Returns a string from the elements of an array
3
join()
Alias of implode()
3
levenshtein()
Returns the Levenshtein distance between two strings
3
localeconv()
Returns locale numeric and monetary formatting information
4
ltrim()
Strips whitespace from the left side of a string
3
md5()
Calculates the MD5 hash of a string
3
md5_file()
Calculates the MD5 hash of a file
4
metaphone()
Calculates the metaphone key of a string
4
money_format()
Returns a string formatted as a currency string
4
nl_langinfo()
Returns specific local information
4
nl2br()
Inserts HTML line breaks in front of each newline in a string
3
number_format()
Formats a number with grouped thousands
3
ord()
Returns the ASCII value of the first character of a string
3
parse_str()
Parses a query string into variables
3
print()
Outputs a string
3
printf()
Outputs a formatted string
3
quoted_printable_decode()
Decodes a quoted-printable string
3
quotemeta()
Quotes meta characters
3
rtrim()
Strips whitespace from the right side of a string
3
setlocale()
Sets locale information
3
sha1()
Calculates the SHA-1 hash of a string
4
sha1_file()
Calculates the SHA-1 hash of a file
4
similar_text()
Calculates the similarity between two strings
3
soundex()
Calculates the soundex key of a string
3
sprintf()
Writes a formatted string to a variable
3
sscanf()
Parses input from a string according to a format
4
str_ireplace()
Replaces some characters in a string (case-insensitive)
5
str_pad()
Pads a string to a new length
4
str_repeat()
Repeats a string a specified number of times
4
str_replace()
Replaces some characters in a string (case-sensitive)
3
str_rot13()
Performs the ROT13 encoding on a string
4
str_shuffle()
Randomly shuffles all characters in a string
4
str_split()
Splits a string into an array
5
str_word_count()
Count the number of words in a string
4
strcasecmp()
Compares two strings (case-insensitive)
3
strchr()
Finds the first occurrence of a string inside another string (alias of strstr())
3
strcmp()
Compares two strings (case-sensitive)
3
strcoll()
Locale based string comparison
4
strcspn()
Returns the number of characters found in a string before any part of some specified characters are found
3
strip_tags()
Strips HTML and PHP tags from a string
3
stripcslashes()
Unquotes a string quoted with addcslashes()
4
stripslashes()
Unquotes a string quoted with addslashes()
3
stripos()
Returns the position of the first occurrence of a string inside another string (case-insensitive)
5
stristr()
Finds the first occurrence of a string inside another string (case-insensitive)
3
strlen()
Returns the length of a string
3
strnatcasecmp()
Compares two strings using a "natural order" algorithm (case-insensitive)
4
strnatcmp()
Compares two strings using a "natural order" algorithm (case-sensitive)
4
strncasecmp()
String comparison of the first n characters (case-insensitive)
4
strncmp()
String comparison of the first n characters (case-sensitive)
4
strpbrk()
Searches a string for any of a set of characters
5
strpos()
Returns the position of the first occurrence of a string inside another string (case-sensitive)
3
strrchr()
Finds the last occurrence of a string inside another string
3
strrev()
Reverses a string
3
strripos()
Finds the position of the last occurrence of a string inside another string (case-insensitive)
5
strrpos()
Finds the position of the last occurrence of a string inside another string (case-sensitive)
3
strspn()
Returns the number of characters found in a string that contains only characters from a specified charlist
3
strstr()
Finds the first occurrence of a string inside another string (case-sensitive)
3
strtok()
Splits a string into smaller strings
3
strtolower()
Converts a string to lowercase letters
3
strtoupper()
Converts a string to uppercase letters
3
strtr()
Translates certain characters in a string
3
substr()
Returns a part of a string
3
substr_compare()
Compares two strings from a specified start position (binary safe and optionally case-sensitive)
5
substr_count()
Counts the number of times a substring occurs in a string
4
substr_replace()
Replaces a part of a string with another string
4
trim()
Strips whitespace from both sides of a string
3
ucfirst()
Converts the first character of a string to uppercase
3
ucwords()
Converts the first character of each word in a string to uppercase
3
vfprintf()
Writes a formatted string to a specified output stream
5
vprintf()
Outputs a formatted string
4
vsprintf()
Writes a formatted string to a variable
4
wordwrap()
Wraps a string to a given number of characters
4
PHP String Constants
PHP: indicates the earliest version of PHP that supports the constant.
Constant Description PHP
CRYPT_SALT_LENGTH

Contains the length of the default encryption method for thesystem. For standard DES encryption, the length is 2

CRYPT_STD_DES

Set to 1 if the standard DES-based encryption with a 2 character salt is supported, 0 otherwise

CRYPT_EXT_DES

Set to 1 if the extended DES-based encryption with a 9 character salt is supported, 0 otherwise

CRYPT_MD5

Set to 1 if the MD5 encryption with a 12 character salt starting with $1$ is supported, 0 otherwise

CRYPT_BLOWFISH

Set to 1 if the Blowfish encryption with a 16 character salt starting with $2$ or $2a$ is supported, 0 otherwise0

HTML_SPECIALCHARS


HTML_ENTITIES


ENT_COMPAT


ENT_QUOTES


ENT_NOQUOTES


CHAR_MAX


LC_CTYPE


LC_NUMERIC


LC_TIME


LC_COLLATE


LC_MONETARY


LC_ALL


LC_MESSAGES


STR_PAD_LEFT


STR_PAD_RIGHT


STR_PAD_BOTH

PHP XML Parser Introduction

The XML functions lets you parse, but not validate, XML documents.
XML is a data format for standardized structured document exchange. More information on XML can be found in our XML Tutorial.
This extension uses the Expat XML parser.
Expat is an event-based parser, it views an XML document as a series of events. When an event occurs, it calls a specified function to handle it.
Expat is a non-validating parser, and ignores any DTDs linked to a document. However, if the document is not well formed it will end with an error message.
Because it is an event-based, non validating parser, Expat is fast and well suited for web applications.
The XML parser functions lets you create XML parsers and define handlers for XML events.
Installation
The XML functions are part of the PHP core. There is no installation needed to use these functions.
PHP XML Parser Functions
PHP: indicates the earliest version of PHP that supports the function.
Function Description PHP
utf8_decode()
Decodes an UTF-8 string to ISO-8859-1
3
utf8_encode()
Encodes an ISO-8859-1 string to UTF-8
3
xml_error_string()
Gets an error string from the XML parser
3
xml_get_current_byte_index()
Gets the current byte index from the XML parser
3
xml_get_current_column_number()
Gets the current column number from the XML parser
3
xml_get_current_line_number()
Gets the current line number from the XML parser
3
xml_get_error_code()
Gets an error code from the XML parser
3
xml_parse()
Parses an XML document
3
xml_parse_into_struct()
Parse XML data into an array
3
xml_parser_create_ns()
Create an XML parser with namespace support
4
xml_parser_create()
Create an XML parser
3
xml_parser_free()
Free an XML parser
3
xml_parser_get_option()
Get options from an XML parser
3
xml_parser_set_option()
Set options in an XML parser
3
xml_set_character_data_handler()
Set handler function for character data
3
xml_set_default_handler()
Set default handler function
3
xml_set_element_handler()
Set handler function for start and end element of elements
3
xml_set_end_namespace_decl_handler()
Set handler function for the end of namespace declarations
4
xml_set_external_entity_ref_handler()
Set handler function for external entities
3
xml_set_notation_decl_handler()
Set handler function for notation declarations
3
xml_set_object()
Use XML Parser within an object
4
xml_set_processing_instruction_handler()
Set handler function for processing instruction
3
xml_set_start_namespace_decl_handler()
Set handler function for the start of namespace declarations
4
xml_set_unparsed_entity_decl_handler()
Set handler function for unparsed entity declarations
3
PHP XML Parser Constants
Constant
XML_ERROR_NONE (integer)
XML_ERROR_NO_MEMORY (integer)
XML_ERROR_SYNTAX (integer)
XML_ERROR_NO_ELEMENTS (integer)
XML_ERROR_INVALID_TOKEN (integer)
XML_ERROR_UNCLOSED_TOKEN (integer)
XML_ERROR_PARTIAL_CHAR (integer)
XML_ERROR_TAG_MISMATCH (integer)
XML_ERROR_DUPLICATE_ATTRIBUTE (integer)
XML_ERROR_JUNK_AFTER_DOC_ELEMENT (integer)
XML_ERROR_PARAM_ENTITY_REF (integer)
XML_ERROR_UNDEFINED_ENTITY (integer)
XML_ERROR_RECURSIVE_ENTITY_REF (integer)
XML_ERROR_ASYNC_ENTITY (integer)
XML_ERROR_BAD_CHAR_REF (integer)
XML_ERROR_BINARY_ENTITY_REF (integer)
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF (integer)
XML_ERROR_MISPLACED_XML_PI (integer)
XML_ERROR_UNKNOWN_ENCODING (integer)
XML_ERROR_INCORRECT_ENCODING (integer)
XML_ERROR_UNCLOSED_CDATA_SECTION (integer)
XML_ERROR_EXTERNAL_ENTITY_HANDLING (integer)
XML_OPTION_CASE_FOLDING (integer)
XML_OPTION_TARGET_ENCODING (integer)
XML_OPTION_SKIP_TAGSTART (integer)
XML_OPTION_SKIP_WHITE (integer)

PHP Zip File Introduction

The Zip files functions allows you to read ZIP files.

Installation

For the Zip file functions to work on your server, these libraries must be installed:
The ZZIPlib library by Guido Draheim: Download the ZZIPlib library
The Zip PELC extension: Download the Zip PELC extension
Installation on Linux Systems


PHP 5+:
Zip functions and the Zip library is not enabled by default and must be downloaded from the links above. Use the --with-zip=DIR configure option to include Zip support.
Installation on Windows Systems
PHP 5+:
Zip functions is not enabled by default, so the php_zip.dll and the ZZIPlib library must be downloaded from the link above. php_zip.dll must be enabled inside of php.ini.
To enable any PHP extension, the PHP extension_dir setting (in the php.ini file) should be set to the directory where the PHP extensions are located. An example extension_dir value is c:\php\ext.

PHP Zip File Functions

PHP: indicates the earliest version of PHP that supports the function.

Function Description PHP
zip_close()
Closes a ZIP file
4
zip_entry_close()
Closes an entry in the ZIP file
4
zip_entry_compressedsize()
Returns the compressed size of an entry in the ZIP file
4
zip_entry_compressionmethod()
Returns the compression method of an entry in the ZIP file
4
zip_entry_filesize()
Returns the actual file size of an entry in the ZIP file
4
zip_entry_name()
Returns the name of an entry in the ZIP file
4
zip_entry_open()
Opens an entry in the ZIP file for reading
4
zip_entry_read()
Reads from an open entry in the ZIP file
4
zip_open()
Opens a ZIP file
4
zip_read()
Reads the next entry in a ZIP file
4

Sunday, June 21, 2009

Introduction to PHP & MySQL

PHP Training Overview
MySQL™ and PHP are two of the most popular open source technologies to emerge during the past decade. PHP is a powerful language for writing server-side Web applications. MySQL is the world's most popular open source database. Together, these two technologies provide you with a powerful platform for building database-driven Web applications.
This hands-on MySQL and PHP training course teaches attendees everything they need to successfully build data-driven Web sites using MySQL and PHP.
Accelebrate also offers an Advanced PHP training class.
Important Note: Upon request, we would be glad to teach this course with a database other than MySQL.
Location and Pricing
Most Accelebrate courses are taught on-site at our clients' locations worldwide for groups of 3 or more attendees and are customized to their specific needs. Please visit our client list to see organizations for whom we have recently delivered training. These courses can also be delivered as live, private online classes for groups that are geographically dispersed or wish to save on the instructor’s or students’ travel expenses. To receive a customized proposal and price quote private training at your site or online.
In addition, some courses are available as live, online classes for individuals. To see a schedule of online courses.
PHP Training Prerequisites
All MySQL and PHP training attendees must be fluent in HTML. The course can be customized to any level of programming and relational database familiarity.
Hands-on/Lecture Ratio
This MySQL and PHP training class is 70% hands-on, 30% lecture, with the longest lecture segments lasting for 10 minutes. Students "learn by doing," with immediate opportunities to apply the material they learn to real-world problems.
PHP Training Materials
All MySQL and PHP training students receive a copy of Apress' Beginning PHP and MySQL 5: From Novice to Professional and related courseware.
Software Needed on Each Student PC
The following should be installed on each student PC:
Linux, Windows, MacOS X, or Solaris operating system
Web server (either Apache httpd or Microsoft IIS)
PHP 5 or later with the PEAR extensions enabled
MySQL 4.1 or later (5 or later recommended)
Internet Explorer 6 or later or Firefox 2 or later
Note: XAMPP, provides a single installer with everything you need for the class on Linux, Windows, MacOS X, or Solaris.
PHP Training Objectives
*To teach attendees the PHP programming skills they need to successfully build interactive, data-driven sites
*To teach students enough MySQL database skills to build the databases that will power their sites
PHP Training Outline
*PHP Basics
How PHP Works
The php.ini File
Basic PHP Syntax
*PHP Tags
*PHP Statements and Whitespace
*Comments
*PHP Functions
*Hello World!

PHP Tags
PHP Statements and Whitespace
Comments
PHP Functions
Hello World!
Variables
*Variable Types
*Variable Names (Identifiers)
*Type Strength
*Hello Variables!
*Variable Scope
*Superglobals
*Constants
*Variable-Testing and Manipulation Functions

Variable Types
Variable Names (Identifiers)
Type Strength
Hello Variables!
Variable Scope
Superglobals
Constants
Variable-Testing and Manipulation Functions
PHP Operators
Creating Dynamic Pages
*Single Quotes vs. Double Quotes
*Howdy World!

Single Quotes vs. Double Quotes
Howdy World!
Conclusion
*Flow Control
Conditional Processing
*If Conditions
If Conditions
Loops
*while
*do...while
*for
*break and continue
while
do...while
for
break and continue
Conclusion
*Arrays
Enumerated Arrays
*Initializing Arrays
*Appending to an Array
*Reading from Arrays
*Looping through Arrays

Initializing Arrays
Appending to an Array
Reading from Arrays
Looping through Arrays
Associative Arrays
*Initializing Associative Arrays
*Reading from Associative Arrays
*Looping through Associative Arrays
*Superglobal Arrays

Initializing Associative Arrays
Reading from Associative Arrays
Looping through Associative Arrays
Superglobal Arrays
Two-dimensional Arrays
*Reading from Two-dimensional Arrays
*Looping through Two-dimensional Arrays

Reading from Two-dimensional Arrays
Looping through Two-dimensional Arrays
Array Manipulation Functions
Conclusion
PHP and HTML Forms
HTML Forms
*How HTML Forms Work
*A Sample HTML Form
*Form Variables

How HTML Forms Work
A Sample HTML Form
Form Variables
Conclusion
*String Manipulation
Formatting Strings
*Concatenation
*String Manipulation Functions
*Examples of String Functions

Concatenation
String Manipulation Functions
Examples of String Functions
Magic Quotes
*magic_quotes_gpc
*magic_quotes_runtime
*Recommendation on Magic Quotes
*Conclusion

magic_quotes_gpc
magic_quotes_runtime
Recommendation on Magic Quotes
Conclusion
*Reusing Code and Writing Functions
Including Files
*require
*require_once
*auto_prepend_file and auto_append_file

require
require_once
auto_prepend_file and auto_append_file
User Functions
*Defining and Calling Functions
*Default Values
*Variable Scope
*By Reference vs. By Value

Defining and Calling Functions
Default Values
Variable Scope
By Reference vs. By Value
Form Processing
*Code Organization
Code Organization
Conclusion
*Simple SELECTs
Introduction to the Northwind Database
Some Basics
*Comments
*Whitespace and Semi-colons
*Case Sensitivity

Comments
Whitespace and Semi-colons
Case Sensitivity
SELECTing All Columns in All Rows
SELECTing Specific Columns
Sorting Records
*Sorting By a Single Column
*Sorting By Multiple Columns
*Sorting By Column Position
*Ascending and Descending Sorts

Sorting By a Single Column
Sorting By Multiple Columns
Sorting By Column Position
Ascending and Descending Sorts
The WHERE Clause and Operator Symbols
*Checking for Equality
*Checking for Inequality
*Checking for Greater or Less Than
*Checking for NULL
*WHERE and ORDER BY
Checking for Equality
Checking for Inequality
Checking for Greater or Less Than
Checking for NULL
WHERE and ORDER BY
The WHERE Clause and Operator Words
*The BETWEEN Operator
*The IN Operator
*The LIKE Operator
*The NOT Operator

The BETWEEN Operator
The IN Operator
The LIKE Operator
The NOT Operator
Checking Multiple Conditions
*AND
*OR
*Order of Evaluation

AND
OR
Order of Evaluation
Conclusion
*Subqueries, Joins and Unions
Subqueries
Joins
*Table Aliases
*Multi-table Joins
Table Aliases
Multi-table Joins
Outer Joins
Unions
*UNION ALL
*UNION Rules

UNION ALL
UNION Rules
Conclusion
*Inserting, Updating and Deleting Records
INSERT
UPDATE
DELETE
Conclusion
Managing Data
Querying a Database
*mysqli() Overview
*mysqli Methods and Properties
*Inserting and Updating Records
*mysqli Prepared Statements

mysqli() Overview
mysqli Methods and Properties
Inserting and Updating Records
mysqli Prepared Statements
*PEAR:DB
Advantages and Disadvantages of PEAR DB
*Why use a database abstraction layer?
*When not to use a database abstraction layer?
Why use a database abstraction layer?
When not to use a database abstraction layer?
Using PEAR DB
*Authentication with PHP and SQL
A Database-less Login Form
Conclusion
*Regular Expressions
Perl-compatible Regular Expression Functions
*preg_match()
*preg_replace()
*Regular Expression Tester

preg_match()
preg_replace()
Regular Expression Tester
Regular Expression Syntax
*Start and End ( ^ $ )
*Number of Occurrences ( ? + * {} )
*Common Characters ( . \d \D \w \W \s \S )
*Grouping ( [] )
*Negation ( ^ )
*Subpatterns ( () )
*Alternatives ( )
*Escape Character ( \ )

Start and End ( ^ $ )
Number of Occurrences ( ? + * {} )
Common Characters ( . \d \D \w \W \s \S )
Grouping ( [] )
Negation ( ^ )
Subpatterns ( () )
Alternatives ( )
Escape Character ( \ )
Form Validation Functions with Regular Expressions
Conclusion
*Session Control and Cookies
Sessions
*Configuring Sessions
*Session Functions
Configuring Sessions
Session Functions
Cookies
Conclusion
*Sending Email with PHP
mail()
*Shortcomings of mail()
Shortcomings of mail()
PHPMailer
Conclusion
*File System Management
Opening a File
*fopen()
fopen()
Reading from a File
*fgets()
fgets()
Writing to a File
*fwrite()
fwrite()
File Locking
*flock()
flock()
Uploading Files via an HTML Form
Getting File Information
More File Functions
Directory Functions
*Getting a Directory Listing
Getting a Directory Listing
*Conclusion

Advanced PHP Training

Advanced PHP Training Overview
Accelebrate's Advanced PHP training teaches experienced PHP developers the object-oriented, XML, PHP, web services, Ajax, and Smarty skills they need to build complex, data-driven, scalable applications.
Location and Pricing
Most Accelebrate courses are taught on-site at our clients' locations worldwide for groups of 3 or more attendees and are customized to their specific needs. Please visit our client list to see organizations for whom we have recently delivered training. These courses can also be delivered as live, private online classes for groups that are geographically dispersed or wish to save on the instructor’s or students’ travel expenses. To receive a customized proposal and price quote private training at your site or onlin.In addition, some courses are available as live, online classes for individuals. To see a schedule of online courses.
Advanced PHP Training Prerequisites
All attendees must be familiar with the fundamentals of building data-driven PHP web applications, either from their own experience or from Accelebrate's Introduction to PHP and MySQL training.
Hands-on/Lecture Ratio
This PHP training class is 70% hands-on, 30% lecture, with the longest lecture segments lasting for 10 minutes. Students "learn by doing," with immediate opportunities to apply the material they learn to real-world problems.
Advanced PHP Training Materials
All attendees receive comprehensive courseware and a copy of O'Reilly's PHP Cookbook.
Software Needed on Each Student PC
The following should be installed on each student PC:
Linux, Windows, MacOS X, or Solaris operating system
Web server (either Apache httpd or Microsoft IIS)
PHP 5.2 or later with the PEAR extensions enabled
MySQL™ 4.1 or later (5 or later recommended), Microsoft SQL Server 2005, Microsoft Access 2000 or later, or Oracle 8i or later
Internet Explorer 6 or later or Firefox 2 or later
Advanced PHP Training Objectives
Learn how to program in Object-Oriented PHP
Learn to process XML with PHP
Learn to work with the PEAR HTTP_REQUEST Module
Learn to work with XML RPC and PHP
Learn to create PHP Web Services
Learn to work with Smarty Templates to speed up PHP development
Advanced PHP Training Outline
*Object-Oriented PHP
Building a Class
Working with Properties and Functions
Private, Protected, Public modifiers
Inheritance
Interfaces
Building a Web Page Object
PHP Objects in N-Tier Web Architecture
Importance of PHP Business Objects
*PHP XML Support
Simple XML Object
Executing XPath Queries
DOM Interoperability
Using XPath
Installing and Configuring LIBXSL
Applying Server side XSL Transformations
Using XML in N-Tier Architecture
Mixing PHP Objects and XML
*PEAR: HTTP_REQUEST MODULE
Installing PEAR::HTTP_REQUEST with Dependencies
HTTP_REQUEST Capability
HTTP GET Request
HTTP POST Request
Programmatically Posting to a HTML Form
Parsing the Response
Building a Basic Authentication PHP Client
*XML RPC
XML-RPC Implementations
Installing and Configuring PHPXMLRPC
XML RPC Data-Types
XML RPC Server
XML RPC Client
XML RPC Request and Response
Exploring the XML RPC API
*PHP Web Services
Web Service Technulogy Stack
SOAP Soup
Web Services with PHP
Installing NuSOAP
Building a SOAP SERVER
Consuming a Web Service
Generating WSDL Dynamically
Understanding Generated WSDL
WSDL and SOAP Proxies
*Complex PHP Web Services
Building Interoperable Web Services
Generating and Handling SOAP Faults
RPC Vs. Document Message Encoding
Serializing the SOAP Envelope
Web Service Best Practices
*Ajax with PHP
Ajax Overview
Ajax Technulogy Stack
Ajax Implementations
Installing and configuring HTML_Ajax Pear Module
Ajax Server
Ajax Client
*Smarty Templates
Smarty Overview
Installing and configuring Smarty Pear Module
Setting up a Template
Passing Data to the Template
Smarty for Template Designers
Smarty for Programmers
Smarty in N-Tier Architecture
*Conclusion

Building Data-Driven PHP Web Sites with Dreamweaver Training

PHP with Dreamweaver Training Overview
Accelebrate's Building Data-Driven PHP Web Sites with Dreamweaver training class teaches attendees the Dreamweaver and PHP skills they need to integrate databases with their Web site.
Location and Pricing
Most Accelebrate courses are taught on-site at our clients' locations worldwide for groups of 3 or more attendees and are customized to their specific needs. Please visit our client list to see organizations for whom we have recently delivered training. These courses can also be delivered as live, private online classes for groups that are geographically dispersed or wish to save on the instructor’s or students’ travel expenses. To receive a customized proposal and price quote private training at your site or online.
In addition, some courses are available as live, online classes for individuals.
PHP with Dreamweaver Training Prerequisites
Accelebrate's Beginning Macromedia Dreamweaver 8, Introduction to Adobe Dreamweaver CS3, or equivalent experience.
Alternative Class
If you are interested in learning PHP programming, we encourage you to consider our Introduction to PHP & MySQL training class.
Hands-on/Lecture Ratio
This Dreamweaver training class is 70% hands-on, 30% lecture, with the longest lecture segments lasting for 15 minutes. Students "learn by doing," with immediate opportunities to apply the material they learn to real-world problems.
PHP with Dreamweaver Training Materials
All students for this Dreamweaver training class receive a copy of Macromedia Press' Macromedia Dreamweaver with ASP, ColdFusion, and PHP: Training from the Source and related courseware.
Software Needed on Each Student PC
Firefox 2.0 or later or Internet Explorer 6 or later
Dreamweaver 8, CS3, or later (course can also be taught using Dreamweaver MX 2004 or MX)
Microsoft Internet Information Server, Apache Web server, Tomcat, or another appropriate Web server software package.
A database server, such as MySQL™ (free), SQL Server, or Oracle (this can be installed on each student PC or on a server reachable over the network from these PCs)
PHP with Dreamweaver Training Objective
To learn how to build data-driven Web sites using Dreamweaver, PHP, and a database
PHP with Dreamweaver Training Outline
*Introduction
Roles of server-side languages
Choosing a server-side language
Which server-side language is best?
Overview of PHP and its requirements
Goals of this class / Who is this class for?
*Creating a Dreamweaver site
Site creation - basic
Site creation - advanced
*Database connections
Database basics
Introduction to SQL
Server behaviors
*Querying the database
Building a SQL query using the Simple view
Building a SQL query using the Advanced view
Adding fields from the resulting records to your page
*Displaying and formatting query results
Using Repeat Region to display multiple records
Formatting results
*Paging through records
Schemes for recordset navigation
Paging to first, last, previous, and next records
*Show region if...
Selectively displaying information based on a conditional
Disabling the first and previous record links if the first page of results is displayed
Disabling the last and next record links if the last page of results is displayed
*Displaying the count of the number of records returned
*Creating master-detail views

Overview of the importance of master-detail views and how they convey information
Creating a master-detail view
*Advanced recordsets and multi-table queries
Method 1 - Simple recordset with filter
Method 2 - Advanced recordset
Method 3 - Advanced recordset and multi-table Queries
*Dynamically populating forms
Populating text fields, text areas, and hidden fields
Populating selection lists, radio button lists, and checkboxes
*Building record insertion forms
Building the insertion form by hand
Allowing Dreamweaver to generate the record insertion form automatically
Creating a page that confirms the record insertion
Validating form entries using JavaScript behaviors
*Understanding stored procedures
How they are created in the database
Advantages/disadvantages of stored procedures versus SQL
Calling a stored procedure without passing parameters
Passing input parameters to a stored procedure
Retrieving parameters from a stored procedure
*Updating records
Manually constructing a form that allows the user to update a record
Using Dreamweaver to automatically generate a form for updating the record
Validating the edited information using JavaScript behaviors
Building a confirmation page to display the result of updating the record
*Deleting records
Precautions to take to ensure that records are not inadvertently deleted
Building an appropriate record deletion interface, complete with confirmation dialog
*Implementing user login/logout with Dreamweaver
Overview of Web application security issues
Preferred approach: configuring the Web server to manage security
Alternative approach: having Dreamweaver automatically generate code for logging users in, authenticating them, and logging them out
In-depth instruction on using Dreamweaver with PHP to implement user login/logout and page-by-page authentication
*Conclusion

Thursday, June 18, 2009

Browser detection with php

This tutorial explains how to make a code only works in one separated browser, I think that's useful to correct incompatibility of page style in some browsers.

In your page, put:

1.2.
3.$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
4.if(strpos($user_agent, 'Opera') !== false)
5.{
6. echo 'code for Opera';
7.}
8.elseif(strpos($user_agent, 'Gecko') !== false)
9.{
10. echo 'code for Mozilla/Firefox';
11.}
12.elseif(strpos($user_agent, 'MSIE') !== false)
13.{
14. echo 'code for IE';
15.}
16.else
17.{
18. echo 'some other browser';
19.}
20.
21.?>

mySQL Grant Command

You can use the mySQL GRANT command to give priveledges to users to a specific database.
The syntax is as follows and follows the standard mySQL keywords and syntax you would perhaps use in a PHP script.
Code: [hide]
Code: [show]
GRANT privileges
ON databasename.tablename
TO username#host
IDENTIFIED BY "password";
The priveledges you can grant to a user are vast and for added security, you should only grant permissions to a users on a database that are requried by your application:
*ALL (all privileges)
*ALTER
*CREATE
*DELETE
*DROP
*FILE
*INDEX
*INSERT
*PROCESS
*REFERENCES (not used currently)
*RELOAD
*SELECT
*SHUTDOWN
*UPDATE
*USAGE (can connect but no privileges)
*Example use of the above syntax and privileges:
*Code: [hide]
*Code: [show]
GRANT SELECT, INSERT
ON mydatabase.*
TO user#domain.com
IDENTIFIED BY "somepassword"
The above wildcard (*) will replace the entire list of tables in the database. You can specify just specify one table name if required. You can also specify an IP Address for the domain part of the "TO" command.
You can revoke privileges using the following syntax:
Code: [hide]
Code: [show]
REVOKE privileges
ON databasename.tablename
FROM username#hostname
Usually, only server administrators should worry about this kind of permission configuration. If you are a normal webmaster using a typical control panel such as Cpanel - all this is done behind the scenes and you will not need to worry about setting up such code.

PHP Operators

Introduction
An operator is used to operate on values. In a basic example, we use an addition operator to add 1+9 together. In another basic example, we use a subtract operator to take away 1 from 10 (10-1). PHP Operators are split into the following categories and shall be explained later in the article:
*Arithmetic Operators
*Assignment Operators
*Comparison Operators
*Logical Operators
Arithmetic Operators
1.Addition (+), eg: x+y
2.Subtraction (-), eg: x-y
3.Multiplication (*), eg: x*y
4.Division (/), eg: x/y
5.Modulus (%), eg: x%y
6.Increment (++), eg x++
7.Decrement (--), eg y--
Assignment Operators
1. =, eg: x=y
2. +=, eg: x+=y, AKA: x=x+y
3. -=, eg: x-=y, AKA: x=x-y
4. *=, eg: x*=y, AKA: x=x*y
5. /=, eg: x/=y, AKA: x=x/y
6.%=, eg: x%=y, AKA: x=x%y
Comparison Operators
1.Not equal to (!=), eg: 18!=13 returns true
2.Greater than (>), eg: 18>13 returns true
3.Less than (<), eg: 18<13 returns false
4.Greater than or equal to (>=), eg: 18>=13 returns true
5.Less than or equal to (<=), eg: 18<=13 returns false
Logical Operators
1.And (&&), eg: (1<2>4) returns true
2.Or (), eg: (1==5 2==10) returns false
3.Not (), eg: !(5==10) returns true
Conclusion
Operators are mainly seen during assignment of a value to a variable or during a conditional statement or a looping structure. They are very powerful are can be used to determine the output of a script, procedure or function to be run.

Looping with PHP and for()

Introduction
The for() function is an iterative function. The word iteration is basically a posh word for looping. You use looping to avoid spaghetti code, and generate a list of output without having to type it all manually. For example, a looping function, for() can be used to loop the 10 times table without having to type it all out manually. Of course, there are much more practical uses for for(), but this tutorial is to tell you how to use this function so you can integrate it into your own projects.
The function
for() loop is used to loop for a set number of iterations. The function takes the following syntax. The following syntax illustrates the function using pseudo code.
Code: [hide]
Code: [show]
for ( initialize a counter; conditional statement; increment a counter)
{
do this code;
} 'initialize a counter' is used to set a start value for the loop. For example, we want to stop looping from the value 0, we set the initialisation counter as 0. 'conditional statement' is used to set a stop value for the loop. This is usually in the form of a conditional statement or in the form of a set value. Thinking about it as a stop value, we can set this to 10. 'increment a counter' is used to set the amount to increment each iteration. For example, we could set the for() loop to increment + 2 each iteration, or + 1 each iteration (in which cause you would use ++ operand). Example Code
The following is an example use of for().
Code: [hide]
Code: [show]
$num = 10;
for ($i = 0; $i <= $num; $i++)
{
echo $i;
} The above code will increment +1 each iteration, from a start value of 0 to a stop value of 10. On each iteration $i is echoed. The second parameter 'conditional statement' can take many forms such as sizeof($bla) and count($bla).
Optimisations
In the previous section, it was mentioned that you can use different forms (thus functions) in the second parameter 'conditional statement'. Bearing this in mind, the function is called each iteration, thus slowing your procedure down. Therefore, on larger looping structures, consider determining the size of the stop value before the loop or consider using something like below:
Code: [hide]
Code: [show]
for ($i = 0, $size = sizeof($bla); $i < $size; $i++)
{
echo $i;
} In the above code, the size of $size is determined within the function, but still only calculated once.
Summary
To conclude, the for() loop is an iterative function of which we know how many iterations to be executed and carried out by the program code.

Building Blocks of PHP

Understand the linguistic terms of PHP, including boolean, operators, variables and constants.
Variables
A variable is a special container that you can define, which will then contain a value you specify. For example a number, string, object, array or boolean.
Constants
If you want to work with a value that needs to remain unchanged, you can define and use a constant variable. This isdifferent to a variable as variables offer a flexible way of storing data as you can change their values and type of data they hold.
Globals and Superglobals
In addition to global declerations aof your own, PHP has built in predefined variables called superglobals. These are always present and the value they hold can be available in all your scripts.
Predefined Constants
PHP provides some built in constants for you. For example __FILE__ returns the name of the file that PHP is using. __LINE__ returns the line number that php is running and PHP_VERSION returns what php version your script is being run on.
Data types
Different types of data will take up different amounts of memory and may then be treated different in the script that you write. PHP will automatically determine the data type for the variable the time data is assigned to it. Some examples of data types are boolean, integer, float, string, object, array, resource, null (an uninitialized value).
The Assignment operator
The equals sign (=) is an assignment operator and will put the value on the right hand site and assign it to the left hand side.
Arithmetic Operators
Arithmetic operators perform mathematic operations on the values you want them to (providing they are a number). Some examples are addition (+), subtraction (-), division (/), multiplication (*), modulus (%). You can increment numbers by putting two addition operators nxet to eachother like so: (++). PHP provides combined operators which allow you to transform the left hand operand and return a result, while also modifying the original value of the variable. To return 'x' and and 5 to 'x' on the same line you would use '$x +=5.'
The Concatanation Operator
The concatanation operator allows you to join strings together. It is represented by a single period (.). Expressions, calculations and variables can also be concataned and the data type returned will aloways be that of a string.
The Comparison Operator
Comparison operators perform comparative tests using their operands and return the boolean value true if the test is succesful and false if it false. Some examples are Equivalence (==), Non-equivalence (!=), greater than (>), less than or equal to (<=). You can use logical operators such as Or (), and (&&) and Not (!) to extend comparisons using the if() statement.

Tuesday, June 16, 2009

Keyboard Shortcut Keys in photoshop

The following are some of the short cut keys that are available in Photoshop 5. Presumably most (if not all) of them should also be available in other versions of Photoshop. (Except where indicated, Mac users should substitute the Command key wherever the CTRL key is mentioned below.)
CTRL+A
Select All (Select menu)
CTRL+B
Adjust Colour Balance (Image menu)
CTRL+C
Copy (Edit menu)
Shift+CTRL+C
Copy Merged (Edit Menu)
CTRL+D
Deselect (Select menu)
Shift+CTRL+D
Reselect (Select menu)
CTRL+E
Merge Down (Layer menu)
Shift+CTRL+E
Merge Visible (Layer menu)
CTRL+F
Last Filter (Filter menu)
Shift+CTRL+F
fade (Filter menu)
CTRL+G
Group with Previous (Layer menu)
Shift+CTRL+G
Ungroup (Layer menu)
CTRL+H
Hide Edges (View menu)
Shift+CTRL+H
Hide Path (View menu)
CTRL+I
Adjust Invert (Image menu)
Shift+CTRL+I
Invert Selection (Select menu)
CTRL+J
New Layer via Copy (Layer menu)
Shift+CTRL+J
New Layer via Cut (Layer menu)
CTRL+K
General Preferences (File menu)
CTRL+L
Adjust Levels (Image menu)
Shift+CTRL+L
Adjust Auto Levels (Image menu)
CTRL+M
Adjust Curves (Image menu)
CTRL+N
New (File menu)
Shift+CTRL+N
New Layer (Layer menu)
CTRL+O
Open (File menu)
Alt+CTRL+O
Open As (File menu)
CTRL+P
Print (File menu)
Shift+CTRL+P
Page Setup (File menu)
CTRL+R
Show Rulers (View menu)
CTRL+S
Save (File menu)
Shift+CTRL+S
Save As (File menu)
Option+Command+S
Save a Copy (File menu - Mac only).
CTRL+T
Free Transform (Edit menu)
Shift+CTRL+T
Transform Again (Edit menu)
CTRL+U
Adjust Hue/Saturation (Image menu)
Shift+CTRL+U
Adjust Deaturate (Image menu)
CTRL+V
Paste (Edit menu)
Shift+CTRL+V
Paste Into (Edit menu)
CTRL+W
Close (File menu)
CTRL+X
Cut (Edit menu)
CTRL+Y
Preview - CYMK (View menu)
Shift+CTRL+Y
Gamut Warning (View menu)
CTRL+Z
Undo (Edit menu)
CTRL+0
Fit on Screen (View menu)
Shift+CTRL+0
Actual Pixels (View menu - windows only)
Alt+Cmd+0
Actual Pixels (View menu - mac only)
CTRL+]
Arrange - Bring Forward (Layer menu)
Shift+CTRL+]
Arrange - Bring to Front (Layer menu)
CTRL+[
Arrange - Send Backward (Layer menu)
Shift+CTRL+[
Arrange - Send to Back (Layer menu)
CTRL++
Zoom In (View menu)
CTRL+-
Zoom Out (View menu)
CTRL+;
Hide Guides (View menu)
Shift+CTRL+;
Snap to Guides (View menu)
Alt+CTRL+;
Lock Guides (View menu)
CTRL+"
Show Grid (View menu)
Shift+CTRL+"
Snap to Grid (View menu)

How to save a tool with the Tool Preset Palette.

Before I started working on this, I'd never used the Tool Preset Palette. It was just one of those five thousand pull down menus I was always opening by mistake.
As with many things in Photoshop, there are multiple ways to get to the Tool Preset Palette. Here are two:
(1) A pull down menu "Tool Preset Picker" (TPP)on the left of the Options Bar.
(2) A tab on the History Palette.



It works like this.


Choose the tool and settings you wish to save. In this case I have the Pencil tool, set to 4 pixels, and black.
Click on the little Arrow button in the upper right corner of the TPP or the History Palette, and select “New Tool Preset.”



A window will pop up with a field for naming the preset. If the tool is a brush or pencil, an option is provided for saving the color with the preset. You can accept the name PhotoShop offers, or make up your own. You could use your friend's names, but It's easier to keep track of them if the name is relevant (and some of us don't have that many friends).
When you have finished defining your preset tools, use the TPP menu to Save Tool Presets. I recommend saving your new set under a unique name to distinguish it from your default tool presets. (I named mine after my favorite peripheral, “X-keys”).
So now you too can have a 40 pixel, Color Burn Mode, 42% Opacity, Magenta brush named Maggie in your TPP, but you still have to mouse away from the drawing to open the menu and get the tool, right? Not if you keep going.

Thursday, January 8, 2009

Redirection based on browser type

Intro: This tutorial will teach you how to make a script that will redirect users based on their browser type to different pages or url. It is restricted to two browser types only which are Internet Explorer and Netscape Navigator. You are not going to learn how to write this script, but learn how to use Dreamweaver to make such a script.

1:- First open Dreamweaver and make a new page. Go to Window > Behaviors if your behaviors panel is not open. Then click on the + sign and choose Check Browser


2:-You will be shown this window when you choose the Check Browser Option.



Here you should make your choices, I have chosen here if the Browser is:


Netscapte Navigator 4.0 and later - go to www.yahoo.com and if it is Netscape www.google.com
After you make your selection Click OK


3:-Make sure onLoad option is chosen under the Events, we want users to be redirected when this page loads.



You are done, preview your page and see where you are redirected based on your Browser Type.


4:- You could as well redirect all the users who are using Netscape Navigator to one page and Internet Explorer user to other. This way if you have two versions of you website for specific browser types, you could redirect them to respectie pages which are viewed best by their specific browser types. It is matter of how you use this script.


5:-Another option is redirect all four options to one page, then it would become a normal redirection script that all the users to one specific page.


Here is the code that is generated by Dreamweaver after this tutorial:



How to open a Fixed (size) Window

1:-Opening a fixed window can be very useful especially if you want a user to see some useful things in that particular window, it can be a photo gallery or Rules & Regulations that you want to display when the user clicks...etc. You can display anything on it and you can specify the size as well, so that the window size corresponds to the content size. Let's get started.

Open a new page in your Dreamweaver and put a button, download the button below for your working purposes or put your own button if you have one ready. Save the page as fixed_window.html

2:-Now click on the button that you have just inserted to the page, and go to Behaviors Panel. If Behaviors Panel is not open go to Window > Behaviors (Shift + F3) to open it. Click on the plus (+) sign and choose Open Browser Window.

3:-Now, you should see a pop-up window, as shown below.

For URL to Display opton you can enter a Web Address or a page name. For the size of the window you can specify the width and height in pixels. I have specified 500 pixels for width and 400 pixels for height. I know it will be a small window for a page like Google so I have ticked the Resize Handlers. This will display Resize Handlers to the user so that he can adjust it. If you don't tick this it will be a fixed size window 500 by 400 which will not be resizable. Other options are pretty understandable, you can just try them if you don't know what are they for

Click OK.

4:-Now you have almost completed your pop-up window, there is one more thing left which is assiging action to your button. You need to specify an action to your button, whether you want a user to click to see the window, or mouse over it...etc. See your Behaviors Panel again and you should see that the action is already specified, in my case it is onMouseOver. If you want to choose any other action just click on the triangle on the right and you will be displayed with other Actions to choose from.

If you want to Edit your window preferences, such as changing the size or url...etc. Just double click on the Open Browser Window word on the right, in Behaviors Panel.

Now, You are done! That was pretty easy isn't it?

Create Rollover/MouseOver effect

This tutorial will teach you how to do a MouseOver effect on your buttons.
1:-

Download these two buttons to do this tutorial or use your own buttons if you have one.
2:- Open a new page in Dreamweaver, and and press Rollover Image button on the Common panel.

3:- After you have clicked the Rollover Image you should see this pop-up window.

Fill in the empty fields with the respective texts. Give your image a name, if it is a menu item such as About Us in our case, give it "About Us" name. Original Image field is the field which should contain your initial image. Rollover Image field should contain your second image which should show when the user MouseOvers. The last two fields are self explanatory.

Once you finish click OK and save your page. Hit F12 to see your page.

4:-You can see your rollover actions in Behaviors Panel. Go to Window > Behaviors to open the panel if it is not already open. To edit double click on the actions on the right side.

Creating CSS in Dreamweaver MX 2004

1:- I hope you know the advantages of using CSS instead of tags for your texts and even for your overall website designs. I am not going to discuss that here, if you would like to tknow more on CSS advantages please visit CSS Zen Garden. In this tutorial I will discuss how to create CSS tags in Dreamweaver and apply them to texts.

2:- There are two types of CSS creation, one is to create inside the html page and apply to the same page and another to create it as a separate .css file. If you are working with a single page, then it is better to create CSS inside the page, but if you are working with many pages then it is better to create a separate file because that way you can apply this file to your other pages. That will save you time, you will not have to create it again and again for every page. Later it will save you time in updating your page in case if you want to change the size of your text, you just have to change in one file and all the pages will be updated automatically.
3:-
To apply CSS to your current working page, please go to Edit > Preferences > General and tick where it says Use CSS instead of HTML tags and click OK. See below.

Once you make these changes in preferences dreamweaver will apply CSS to your texts whenever you change font size, color, face...etc And it will create CSS codes accordingly under the name style1, style2...etc You can change these names to meaningful words if you want.
4:- To see how it works, open a new page and type some words in the page and change font size or color, and see how it has created a CSS style and applied it to your text. You can see it from properties box as shown below. You can see your CSS styles in your CSS Styles Panel. Go to Window > CSS Styles if the panel is not already open. In CSS Styles Panel you can edit your styles, if you want to edit just right click on your CSS style and choose Edit... and you will be displayed with a pop-up window, where you can specify properties.

5:- We have learned how to create a CSS style inside the page in the previous page, now we will learn how to create a separate CSS file. Open your CSS Styles Panel and click on the New CSS Style button.

6:- You will be shown a new pop-up window like below. Choose a name for your CSS style. For the Selector Type: use Class (can apply to any tag) , and for Define in: use (New Style Sheet File). Press OK.
7:- Give your CSS file a name and Press Save. In step 6 you gave a name to your CSS Style, here you are giving a name to your CSS File. Please note that in one CSS File you can have many CSS Styles, so don't confuse these namings.
8:-Once you press save you will be shown another pop-up window where you define your CSS properties. Please see below. Once you define the properties of your text, Press OK.
After you press OK your new CSS Style will appear in the CSS Styles Panel.

9:-To apply your new CSS Style to any text, just highlight the text and choose your style from Properties Panel.