PHP:



GoDaddy:
Connection String

Windows 7 installation:
1. install C++ 2008 redistributable at: microsoft.com
2a.(choose a or b or c) download php 5.3 at: php.net
2b.(choose a or b or c) download php 5.2.11 at: php.net
2c.(choose a or b or c) download php VC9 x86 Non Thread Safe at: php.net
3. install
copy php.ini to correct directory (C:/PHP)
point to php-cgi.exe in Expression Web Developer, by going to Site - Site Settings - Preview - etc.
un comment-out the mysql extensions (and any others that might apply)


PHP Tutorial - tutorialspoint.com
Installing PHP on a windows system - php.net
Installing extensions on windows - php.net
PHP Tutorial at w3schools.com


commands, functions, keywords:

$ - variable declaration.
strlen(arg1) - function returns integer length of the string argument arg1.
strpos(arg1,arg2) - function returns the integer position of the start of arg2 within the string arg1. The first position is number 0. The function returns false if arg2 not present.

all string functions and constants:

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:

CRYPT_SALT_LENGTH Contains the length of the default encryption method for the system. 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 Operators:

Arithmetic Operators

Operator Description Example Result
+ Addition x=2
x+2 4
- Subtraction x=2
5-x 3
* Multiplication x=4
x*5 20
/ Division 15/5
5/2 3
2.5
% Modulus (division remainder) 5%2
10%8
10%2 1
2
0
++ Increment x=5
x++ x=6
-- Decrement x=5
x-- x=4

Assignment Operators

Operator Example Is The Same As
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y

Comparison Operators

Operator Description Example
== is equal to 5==8 returns false
!= is not equal 5!=8 returns true
<> is not equal 5<>8 returns true
> is greater than 5>8 returns false
< is less than 5<8 returns true
>= is greater than or equal to 5>=8 returns false
<= is less than or equal to 5<=8 returns true

Logical Operators

Operator Description Example
&& and x=6
y=3
(x < 10 && y > 1) returns true

|| or x=6
y=3
(x==5 || y==5) returns false

! not x=6
y=3
!(x==y) returns true


PHP MySQL Functions:

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 mysql_connect() Function

--------------------------------------------------------------------------------
Complete PHP MySQL Reference
--------------------------------------------------------------------------------

Definition and Usage
The mysql_connect() function opens a non-persistent MySQL connection.

This function returns the connection on success, or FALSE and an error on failure. You can hide the error output by adding an '@' in front of the function name.

Syntax
mysql_connect(server,user,pwd,newlink,clientflag)

Parameter Description
server Optional. Specifies the server to connect to (can also include a port number. e.g. "hostname:port" or a path to a local socket for the localhost). Default value is "localhost:3306"
user Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process
pwd Optional. Specifies the password to log in with. Default is ""
newlink Optional. If a second call is made to mysql_connect() with the same arguments, no new connection will be established; instead, the identifier of the already opened connection will be returned
clientflag Optional. Can be a combination of the following constants:
•MYSQL_CLIENT_SSL - Use SSL encryption
•MYSQL_CLIENT_COMPRESS - Use compression protocol
•MYSQL_CLIENT_IGNORE_SPACE - Allow space after function names
•MYSQL_CLIENT_INTERACTIVE - Allow interactive timeout seconds of inactivity before closing the connection



--------------------------------------------------------------------------------

Tips and Notes
Tip: The connection will be closed as soon as the script ends. To close the connection before, use mysql_close().

Tip: To establish a persistent MySQL connection, use mysql_pconnect() instead.


--------------------------------------------------------------------------------

Example
<?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// some code

mysql_close($con);
?>