Embed
Email

php

Document Sample

Shared by: Kerala g
Categories
Tags
Stats
views:
3
posted:
12/7/2011
language:
pages:
41
PHP3.0



PHP version version 3 script language PHP

feature PHP database

database PHP support

 Oracal

 Sybase

 mSQL 1.x and 2.x

 MySQL

 Solid

 Generic ODBC

 PostgreSQL

 Adabas D

 FilePro

 Velocis

 All data system with DOBC interface

 dBase

 Unix dbm





PHP 3 Feature

Feature ข PHP 3



HTTP authentication with PHP



PHP support HTTP Authentication hook Apache module PHP

Apache module Header() function ‛ Authentication Required‛ message

client browser brewser pop up Username/Password input windows

Username/Password PHP $PHP_AUTH_USER,

$PHP_AUTH_PW $PHP_AUTH_TYPE username password type

Basic Authentication PHP support

HTTP Authentication



‛;

echo ‚You entered $PHP_AUTHPW as your password.‛;

}

?>

database password

username



GIF creation with PHP

PHP HTML output PHP GIF image

GIF image compile PHP compile

support GD library

GIF creation with PHP



image

text



File upload support



PHP file upload RFC-1867 browser upload

feature upload binary text file

upload upload

user

File Upload From





Send this file:





URL php html file input hidden



$userfile – The temporary filename in which the uploaded file was stored on the server

machine.

$userfile_name – The original name of file on the sender’s system.

$userfile_size – The size of the uploaded file in bytes.

$userfile_type – The mime type of file the browser provided this information. An

example would be ‚image/gif‛



HTTP cookies support



PHP support HTTP Cookies remote browser user

HTTP set cookies setcookies() cookies

HTTP header browser

HTTP

Cookies client automatically PHP

GET POST method data

Database Support

PHP support database ODBC



Regular expression



Regular expression complex string PHP ereg() ,

ereg_replace() , eregi() , eregi_replace() , split()

regular expression manual site PHP

mirror site http://robot.airl.eng.cmu.ac.th/bigmanual.html

regular expression

ereg(‚abc‛ ,$string); /* Returns true if ‚abc‛ is found anywhere in $string. */

ereg(‚^abc‛ ,$string); /* Returns true if ‚abc‛ is found at the beginning of $string. */

ereg(‚abc$‛ ,$string); /* Returns true if ‚abc‛ is found at the end of $string. */

eregi(‚(ozilla.[23]|MSIE.3)‛,$HTTP_USER_AGENT); /* Returns true if client browser

is Netscape 2, 3 or MSIE 3. */

ereg(‚([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)‛,$string,$regs); /* Places three space

separated words into $regs[1], $regs[2] and $regs[3]. */

ereg_replace(‚^‛,‛‛,$string); /* Put a tag at the beginning of $string. */

ereg_replace(‚$‛,‛‛,$string); /* Put a tag at the end of $string. */

ereg_replace(‚\n‛,‛ ‛,$string); /* Get rid of any carriage return characters in $string. */



Error Handling



error message error global

varible $php_errormsg

Installation

install PHP3 software



 Basic Linux skill

 An ANSI C compiler

 A web server (Apache web server)

install PHP Linux PHP install

win95 NT

1. download PHP version http://www.php.net

version 3.0.4

2.

#gunzip php-3.0.tar.gz

#tar –xvf php-3.0.tar

3. direction php3.0/

#./setup

4. config directory module

 Apache module

 Fhttp module

 CGI Version

 Database support option yes database



5. makeall make install

6. HTTP apache file

phtml script PHP

srm.conf

AddType text/html.phtml

AddType text/html.php3

AddHandler php3-script.php3

Action php3-script / cgi-bin/php

AddHandler php3-script.phtml

Action php3-script / cgi-bin/php







7. Copy php directory php 3.0/ /var/lib/httpd/cgi-bin/ run

http killall –HUP /usr/sbin/httpd

8. php file php

editor vi pico

- pico file

> pico test.phtml /* php script script file

.php3 .phtml */

directory /var/lib/httpd/htdocs

editor





hello from html.







save file Ctrl+x yes

- file browser location http://host.name/test.phtml

http://server_ip/test .phtml

-

- srm.conf compile php source code









FAQ ข PHP http://www.php.net/FAQ.php3

Syntax and grammar



Syntax PHP C , Java Perl



Escaping from HTML

3 PHP HTML ‚PHP code mode‛

5.1

1.

2.

3.

echo (‚some editors (like FrontPage) don’t like processing instructions‛) ;





Instruction separation Variable Types Variable initialization Variable Scope



Scope context PHP

scope user-defined functions

local function scope

default local function scope



$a=1 ; /* global scope */

Function Test() {

Echo $a; /* reference to local scope variable */

}

Test () ;



Script echo local version

$a scope C

C

local

definition global

PHP global







$a=1 ;

$b=2 ;

Function Sum() {

Global $a, $b;

$b = $a + $b;

}

Sum ();

Echo $b;



Script ‚3‛ $a $b

global global version

global manipulate

access global scope special PHP-defined

$GLOVALS array



$a = 1;

$b = 2;

Function Sum() {

$GLOBAL [‚b‛] = $GLOBALS [‚a‛] + $GLOBALS [‚b‛];

}

Sum();

Echo $b;



$GLOBALS



associative array global

element

feature variable scoping static variable static variable

local function scope execution

scope

Function Test() {

$a = 0;

echo $a;

$a++ ;

}

$a 0 print

‚0‛ $a++ $a







$a static

Function Test() {

Static $a=0;

Echo $a;

$a++ ;

}

Test() print

$a



static variable



recursive recursive function

recursive indefinitely

recursive

recursive 0



Function Test () {

Static $count=0;

$count++;

echo $count;

if ($count

A=5



ELSE ELSEIF



print ‚…‛;

elseif ($a= =6)

print ‚a equals to 6‛;

print ‚!!!‛;

else

print ‚a in not 5 or 6‛;

endif;



WHILE

PHP3





โครงสร้าง

while (expr) statement



$i = 1;

while ($i 0);



FOR



loop

โครงสร้าง

for (expr1; expr2; expr3;) statement

expr1 loop

expr2 loop loop

loop expr2

expr3 loop



for ($i = 1; $i ‛;

}

?>

MySQL Function

Mysql_affected_rows

Name

Mysql_affected_rows-

Description

Int mysql_affected_rows(int link_identifier)

Returns :

mysql_affected_rows ()

Server Link identifier link identifier link







mysql_close

Name

Mysql_close- MySQL

Description

Int mysql_close(int link_identfier);

Return: true

False

mysql_close() MYSQL

link identifier link

link



mysql_close() link mysql_pconnect()

See also: mysql_connect(), mysql_pconnect()



Mysql_connect

Name

Mysql_connect- MySQL Server

Description

Int mysql_connect( string hostname, string username, string password);

Return : link identifier

false

mysql_connect() MySQL Server

Argument default (‚localhost‛, user name

server , password )

mysql_connect() argument

link identifier

link Server

mysql_close()

See also: mysql_pconnect, mysql_close



mysql_create_db

Name

mysql_create_db – MySQL

Description

Int mysql_create_db(string database name);

mysql_create_db() Server

Link identifier

See also: mysql_drop_db

mysql_createdb



mysql_data_seek

Name

mysql_data_seek – pointer

Description

Int mysql_data_seek(int result_identifier, int row_number);

Return : true

False

mysql_data_seek() pointer MySQL

result_identifier pointer

row_number mysql_fertch_row

See also : mmysql_data_seek

mysql_dbname

Name

mysql_dbname – MySQL database

Description

String mysql_dbname(string result, int I);

mysql_dbname() database I result

pointer Mysql_list_dbs mysql_num_rows

database



mysql_db_query

Name

mysql_db_query – MySQL Query

Description

Int mysql_db_query(string database, string query, int link_identifier);

Return : MySQL Query

False error

mysql_db_query() database execute query

link_identifier link MySQL

Server link mysql_connect() argument

See also: mysql_connect mysql



Mysql_drop_db

Name

Mysql_drop_db – drop MySQL

Description

Int Mysql_drop_db(string database_name, int link_identifier);

Returns:true

false

Mysql_drop_db() drop(remove) server

link_identifier

See also: mysql_create_db

Mysql_dropdb

mysql_errno

Name

mysql_errno – error mysql

Description

Int nysql_errno();

Error MySQL error

‛;

mysql_select_db(‚nonexistentdb‛);

echo mysql_errno(). ‚ : ‛. mysql_error(). ‚‛;

$conn = mysql_query (‚SELECT * FROM nonexistenttable‛);

echo mysql_errno(). ‚ : ‛ . mysql_error().‛ ‛;

?>

See also: mysql_error



mysql_error

Name

mysql_error – error

Description

String mysql_error();

Error MySQL error

‛;

mysql_select_db(‚nonexistentdb‛);

echo mysql_erron(). ‚ : ‛. mysql_error().‛ ‛;

$conn=mysql_query(‚DELECT * FROM nonexistenttable‛);

echo mysql_erron(). ‚ : ‛. mysql_error().‛ ‛;

?> See also: myalso_erron

mysql_fetch_array

Name

mysql_fetch_array – fetch array

Description

Int mysql_fetch_array(int result);

Return : array fetch

False

mysql_fetch_array() mysql_fetch_row

field Key

mysql_fetch_array()

mysql_fetch_row

See also: mysql_fetch_row



mysql_fetch_field

Name

mysql_fetch_field – field

description

object mysql_fetch_field(int result, int field_offset);

Return : object field

mysql_fetch_field() field query

field_offset field fetch

mysql_fetch_field()

object

 name

 table

 max_length

 not_null-l null

 prinary_key-l Primary key

 unique_ key-l Unique key

 multiple_ key-l non-unique key

 numeric-l

 blob-l BLOB

 type

 unsigned-l Unsigned

 zerofill-l Zerofill

See also : mysql_field_seek



mysql_fetch_lengths

Name

mysql_detch_lengths – data

Description

Int mysql_detch_lengths(int result);

Return : array field fetch

mysql_fetch_row()

False error

mysql_detch_lengths()

fetch mysql_fetch_row() array offset 0

See also: mysql_fetch_row



mysql_fetch_object

Name

mysql_fetch_object – fetch object

Description

Int mysql_fetch_object(int result);

Returns: object fetch

False

mysql_fetch_object() mysql_fetch_array

object access field

offset ( )

See also : mysql_fetch_array แ mysql_fetch_row

mysql_fetch_row

Name

mysql_fetch_row – array

Description

Array mysql_fetch_row(int result);

Return : array fetch

False

mysql_fetch_row() fetch 1 Result

array offset array

offset 0

mysql_fetch_row() result

false

See also : mysql_fetch_array, mysql_fetch_object, mysql_data_seek,

mysql_fetch_lengths แ mysql_result



mysql_fetch_name

Name

mysql_fetch_name – field

Description

String mysql_fetch_name(string result, int I);

Return : field argument result

field index mysql_fetch_name($result,2);

field 2 result

mysql_fetchname



mysql_field_seek

Name mysql_field_seek – offset field

Description

Int mysql_field_seek(int result, int field_offset);

seek field offset mysql_fetch_field()

field offset field

See also: mysql_fetch_field

mysql_field_table

Name

mysql_field_table – field

Description

Int Mysql_field_table(void);

field Mysql_fieldtable







Mysql_field_type

Name

Mysql_field_type – field

Description

String Mysql_field_type(string result, int i);

Mysql_field_type Mysql_field_name()

argument field type ‚int‛ ‚real‛ ‚string‛ ‚blob‛



1 mysql field type

‛;

echo ‚The table has the following fields ‛;

while ($i ‛;

$i++ ;

}

mysql_close();

?>



mysql_fieldtype



mysql_field_flags

Name

mysql_field_flags – field flags

Description

String mysql_field_flags(string result, int i);

mysql_field_flags() field flags field

‚not null‛ ‚primary key‛ ‚‛

mysql_fieldflags

MyODBC Client



1. double click setup.exe MyODBC

- ODBC Driver







- Data Source MySQL Close







- install MyODBC window







2. 32-bit ODBC add MyODBC System DSN

- click Start -> Setting -> Control panel -> 32 bit ODBC

- click System DSN Add..







- Create New Data Source Window MySQL click Finish







- setup ODBC Driver

setup



ข Access MySQL Server



1. Access

2. click table save as/export



3. save as… window To an External File or Database



4. Save as type ODBC Database()

5. table MySQL database



6. config parameter MyODBC Driver connect MySQL Database

Server OK transfer

transfer

1) server IP

2) user (permission) database

,‚ HTML,‛

, 2539.

, ‚ SQL,‛ , 2537.

Date. C.J., ‚ Introduction to Database System ,‛ Sixth Edition, Addison- Wesley , 1995 .

‚Microsoft Visual Basis 4.0‛ ,‛

, 2539.

Stephen Cannan and Gerard Ottn, ‚SQL – The New SQL : A Complete Guide ,‛

McGraw Hill International, 1993

http://www.php.net/documentation.php3

202.44.248.60/mysql-3.21.31/Docs/manual.txt



Related docs
Other docs by Kerala g
union-budget-2012-13-highlights
Views: 81  |  Downloads: 0
notification M.Tech_05-03-09
Views: 56  |  Downloads: 0
India_Customs Regulation 1
Views: 52  |  Downloads: 0
CE Notification 39-2011-12.9.2011
Views: 50  |  Downloads: 0
STATISTICS
Views: 69  |  Downloads: 0
A Hero (R.K. Narayan)
Views: 87  |  Downloads: 6
RRBPatna-Info-HN
Views: 98  |  Downloads: 0
RRB-Notice-Para
Views: 100  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!