Tải bản đầy đủ (.pdf) (10 trang)

Phát triển web với PHP và MySQL - p 87 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (430.95 KB, 10 trang )

insert_book.php script
835
PNG (Portable Network
Graphics), 403
WBMP (Wireless
Bitmap), 403
functions, 428
generating automatically,
410
inline, dynamically
produced, 410
manipulating, 593-595
size, 593
supporting in PHP, 402
Web site, 402
text
drawing or printing on,
406-408
fitting onto buttons,
415-418
outputting, 409
positioning onto
buttons, 418
writing onto buttons,
419
ImageString() function,
407
ImageTTFBBox() function,
417
ImageTTFText() function,
416, 427


IMAP (Internet Message
Access Protocol), 371,
618
IMAP Connection Web
site, 618
IMAP function library,
619-620
imap_body() function, 646
imap_delete() function,
648
imap_expunge() function,
648
imap_fetchheader() func-
tion, 646
imap_header() function,
646
imap_open() function,
642-643
implementing
content management
systems, 598
editor screen, 614-616
headlines.php, 598-602
keywords, 611-614
stories, adding, 602-
611
login, 672-675
PHPBookmark database,
502
front page, 504-506

recommendations, 532-536
implode() function, 102
importing public keys
(Gnu Privacy Guard),
341
include fns.php, 595
include() statement,
127-129
include_fns.php, 660
increment operators,
28-29
indenting code, 39,
465-466
INDEX privilege, 190
index.html, 752-754
index.php, 660
index.php script
(Shopping Cart applica-
tion), 549-553
indexes
database optimization, 262
queries, 261
indexes (arrays), 71
information about data-
bases
DESCRIBE statement, 257
EXPLAIN statement,
257-260
gathering, 254
indexes, 261

SHOW statement, 254-257
Information button, 683
inheritance (object-ori-
ented development),
150, 155-156
multiple inheritance,
157-158
overriding, 156-157
initializing
associative arrays, 73
numerically indexed
arrays, 71-72
ini_get() function, 453-454
ini_set() function, 453-454
inline images, dynami-
cally produced, 410
inner join, 219
input data
checking, 485
validating, 510
input data (Web
databases)
checking, 232-233
filtering, 233
INSERT privilege, 190
INSERT queries, 238-241
INSERT statement, 209
inserting data into
databases, 209-211
insertion anomalies,

avoiding (Web data-
bases), 178
insert_book.php script,
239-240
40 7842 index 3/6/01 4:22 PM Page 835
insert_book.php script (Shopping Cart application)
836
insert_book.php script
(Shopping Cart applica-
tion), 578-579
insert_book_form.php
script (Shopping Cart
application), 578
insert_order() function,
570-572
installing
Apache, 787-789
UNIX environment,
787-789
Windows environment,
795-796
GPG (Gnu Privacy Guard),
339-342
Microsoft IIS, 800-801
Microsoft PWS, 801
mod_auth_mysql module,
322-323
mod_SSL, 787-789
UNIX environment,
787-789

MySQL, 783
UNIX environment,
783-787
Windows environment,
793
PHP, 783
UNIX environment,
783-787
Windows environment,
799-800
SSL, 783-787
instantiation (classes), 152
integral data types
(numeric column types),
201
integrated development
environment. See IDE
interfaces
administration interface
(Shopping Cart applica-
tion), 575-584
PHP database interfaces,
242
Warm Mail application
(email client), 620-621
International PGP Home
Page Web site, 339
Internet, secure
transactions, 330-331
Internet Information

Server (IIS)
basic authentication,
319-321
configuring with Internet
Services Manager,
319-321
Internet Message Access
Protocol (IMAP), 371,
618
Internet Protocol (IP), 333
Internet Services
Manager, configuring IIS
(Internet Information
Server), 319-321
intval() function, 87
IP (Internet Protocol), 333
isset() function, 37, 140
is_uploaded_file() func-
tion, 357
J
join condition, WHERE
clause, 215
join() function, 102
join types (MySQL), 219
joining
strings
implode() function, 102
join() function, 102
tables, 216-217
joins, 219

Cartesian product, 219
cross, 219
equi, 219
equi-joins, 215
EXPLAIN statement, 258
full, 215, 219
inner, 219
left, 217-219
tables, 214
joining, 216-217
two-table, 214-216
Joint Photographic
Experts Group. See JPEG
JPEG (Joint Photographic
Experts Group), 403
jpeg-6b, downloading
(FTP site), 402
Web site, 403
JPEG library Web site, 751
jpeg-6b, downloading
(FTP site), 402
Julian calendar, 399
Julian Day Count
calendar, 399
K
key pairs, installing GPG
(Gnu Privacy Guard), 340
keys
private keys, Gnu Privacy
Guard (GPG), 340

public keys
exporting (Gnu Privacy
Guard), 340
40 7842 index 3/6/01 4:22 PM Page 836
listings
837
Gnu Privacy Guard
(GPG), 340
importing (Gnu Privacy
Guard), 341
keys (arrays), 71
keys (databases), 173-175
creating for Web databases,
179
foreign keys, 175
keyword add.php, 596
keyword delete.php, 596
keywords
AUTO_INCREMENT
keyword, 196
DESC, 220
extends keyword, 155
LIKE, 214
NOT NULL keyword, 196
PRIMARY KEY keyword,
196
REGEXP, 214
return keyword, 140
UNSIGNED keyword, 196
keywords.php, 596

keywords.php file, 611
KPHPDevelop Web site,
469
krsort() function, 80
ksort() function, 79-80
L
language constructs
array(), 71
die(), 450
exit, 450
leaf nodes (Web forum
tree structure), 714
Left join, 219
left joins, 217-218
Lempel Ziv Welch (LZW),
404
length of strings, testing,
105
letters, descenders, 417
libcurl, 387
libraries
FreeType, downloading
Web site, 402
function, 467
developing, 467
function (PHPBookmark
application), 501
PHP, 783
Web sites, 783
PHP database interfaces,

242
libraries (PDF), function,
751
Web sites, 751
LIKE keyword, 214
LIMIT clause, SELECT
statement, 222
line graphs, script for
outputting, 405
lines curved, ImageArc()
function, 428
links (Web forum tree
structure), 713
list archives, viewing,
686-687
list() function, 74-75
listing files in directories,
359
listings
add_bm() Function from
url_fns.php, 528
add_bms.php, 527
bookmark fns.php:Include
File of Functions for the
Bookmark Application,
504
bookmarks.sql:SQL File to
Set Up the Bookmark
Database, 503
change_passwd.php, 519

change_password(), 520
change_password()
Function from
user_auth_fns.php, 691
check_valid_user Function
from user_auth_fns.php,
517
create_database.sql,
661-662
content database, set-
ting up, 597-598
db_connect() Function
from db_fns.php, 513
delete_bm() Function in
url_fns.php, 531
delete_bms.php, 530
delete_story.php, 611
display_information()
Function from
output_fns.php, 684
display_items() Function
from output_fns.php,
680-681
display_mail_form()
Function from
output_fns.php, 696
do_html_header() Function
from output_fns.php, 506
filled_out() Function from
data_valid_fns.php, 510

forgot_passwd.php, 522
functions from
user_auth_fns.php, 669
get_archive() Function
from mlm_fns.php, 686
get_email() function from
mlm_fns.php, 677
40 7842 index 3/6/01 4:22 PM Page 837
listings
838
get_random_word()
Function from
user_auth_fns.php, 524
get_unsubscribed_lists()
Function from
mlm_fns.php, 683
get_user_urls() Function
from url_fns.php, 529
headlines.php, 600
displays page head-
lines, 599
displays published
stories, 601
index.html, 753-754
index.php, 663-669
load_list_info() Function
from mlm_fns.php, 685
login() Function from
user_auth_fns.php, 516,
676

login.php(col)Front Page
of the PHPBookmark
System, 504
logout.php, 518
member.php, 514
notify password() Function
from user_auth_fns.php,
525
orders.txt, 58
page.php, displays pub-
lished stories, 601
pdf.php, 763-764
pdflib.php, 770-774
publish.php, displays docu-
ments to be edited, 614
recommend.php, 534
recommend_urls()
Function from
url_fns.php, 534-536
register() Function from
user_auth_fns.php, 512
register_new.php, 508-509
reset_password() Function
from user_auth_fns.php,
523
resize_image.php, resizes
JPEG image on-the-fly,
593
rtf.php, 759
score.php, 755

search.php, matching sto-
ries, 612-613
send() Function from
mlm_fns.php, 704-707
store_account() Function
from mlm_fns.php, 674
store_list Function from
mlm_fns.php, 694
stories.php, 605-606
create/edit, 607-608
interface for writers,
604
story.php, create/edit sto-
ries, 607-608
subscribe() and unsub-
scribe() Functions from
mlm_fns.php, 688-689
testpdf.php, 766
upload.php, 698-701
uploaded files, code,
358-359
valid_email() Function
from data_valid_fns.php,
511
vieworders.php interface,
59
lists
creating, 693-695
databases, 657
viewing, 679-686

action buttons, 681-682
literal special characters
(regular expressions),
112
literals, 21
LOAD DATA INFILE
statement, 263
load list info() function,
685
loading
arrays from files, 85-87
data from files, 263
extensions, dynamically,
453
local variables, 136
locking files, 65-66
log files, 299-300
Log In button, 675
logging in, 675-678
user authentication,
513-517
Warm Mail application
(email client), 629-631
logging in to FTP servers,
mirroring files, 382
logging in to MySQL,
185-187
logging out, 691
user authentication, 518
Warm Mail application

(email client), 632
logging out of MySQL,
193
logic (code), 471
separating from content,
472
logic errors, 485-486
logical operators, 30-31
login
anonymous login (FTP),
381
implementing, 672-675
login() function, 515, 676
login.php, 501-506, 596
logo.gif, 596
logout.php, 501
40 7842 index 3/6/01 4:22 PM Page 838
members_only.php script (authentication)
839
logout.php files, 605
logout.php script (authen-
tication), 444-445
lookup functions, 374-378
checkdnsrr(), 378
explode(), 377
gethostbyaddr(), 377
gethostbyname(), 376-377
getmxrr(), 376-378
parse_url(), 377
looping through associa-

tive arrays, 74-75
loops, 43-47
accessing numerically
indexed arrays, 73
break statement, 47
do while loops, 47
for loops, 45-46
while loops, 44-45
lstat() function, 364
ltrim() function, 97
Lycos Web site, 787
LZW (Lempel Ziv Welch),
404
M
magic quotes, 448-449
enabling, 546
magic_quotes_gpc
directive, 336
magic_quotes_runtime
directive, 336
Mail Exchange (MX)
records, 378
mail() function, 95, 371,
525, 658
mailbox (Warm Mail
application), viewing
contents of, 640-643
mailing list manager.
See MLM
mail_fns.php library

get_accounts() function,
634
main page (Shopping
Cart application),
549-553
maintainability, code,
463-467
make_button.php file,
412
make_button.php script,
buttons, 411
management systems,
content, 588
building, 588
databases versus file
storage, 590
document structure, 591
editing, 589
editing online, 589
editor screen, 614-616
file upload method, 589
FTP access, 589
headlines.php, 598-602
implementing, 598-611
keywords, 611-614
manipulating images,
593-595
size, 593
many-to-many relation-
ships (databases), 175

Maranda, Steve, 428
matching
regular expressions,
109-114
* symbol, 11
+ symbol, 11
branching, 112
caret symbol (^), 112
character classes,
110-111
character sets,
109-110
curly braces
({}), 112
finding substrings,
114-115
literal special
characters, 112
replacing substrings,
115
slash (\), 112
special characters, 113
splitting strings,
115-116
subexpressions,
111-112
Web references, 116
Substrings, 105-107
Find and replace,
108-109

Numerical position,
107-108
Strpos() function,
107-108
Strrpos() function, 107
Strstr() function,
106-107
With regular
expressions, 114-115
max() function, 141
MAX(column) function,
221
MaxClients parameter
(Apache), 235
max_connections parame-
ter, 235
member.php, 501
members_only.php script
(authentication),
443-444
40 7842 index 3/6/01 4:22 PM Page 839
memory, freeing up (mysql_free_result() function)
840
memory, freeing up
(mysql_free_result()
function), 241-242
message headers (Warm
Mail application),
viewing, 647
messages, sending (online

newsletters), 704-708
meta tags (HTML), 160
metadata, 591
Microsoft IIS (Microsoft
Internet Information
Server), 800
installing, 800-801
Microsoft Internet
Information Server
(Microsoft IIS), 800-801
Microsoft PWS, installing,
801
Microsoft Word RTF,
746-747
Microsoft Word Web site,
746
MIN(column) function,
221
mirroring files, (FTP
functions), 379-385
closing connections, 385
connecting to remote FTP
server, 382
downloading files, 384-385
file update times,
checking, 383-384
logging in to FTP server,
382
MIT Distribution Center
for PGP Web site, 338

mktime() function,
394-395, 398
MLM (mailing list
manager), 656
actions, 670-672
building, 656
files, 660
create_database.sql,
660
data_valid_fns.php,
660
db_fns.php, 660
include_fns.php, 660
index.php, 660
mlm_fns.php, 660
output_fns.php, 660
upload.php, 660
user_auth_fns.php, 660
mlm_fns.php, 660
modeling, real-world
objects (Web data-
bases), 176
modes, file modes, 52
modification anomalies,
avoiding (Web
databases), 177
modification dates
(scripts), 452
modification of data
(security threats), 286

MODIFY [COLUMN]
column_description
syntax, 224
modular names, code,
464
modules, 782-783
PHP, running, 782-783
modulus operator, 26
mod_auth module
(Apache Web server),
316
mod_auth_mysql module,
322-324
documentation Web sites,
324
installing, 322-323
mod_SSL
configuring, 788
installing, 787-789
UNIX environment,
787-789
Mod_SSL Web site, 784
moving files, 364-365
multidimensional arrays,
75-79
sorting, 80
reverse sorts, 82
user defined sorts,
80-82
three-dimensional arrays,

77, 79
two-dimensional arrays,
75-77
contents, accessing, 76
multiple files, uploading,
698-702
multiple inheritance
(object-oriented devel-
opment), 157-158
multiple programmers,
version control (code),
468
multiplication operator,
26
MX (Mail Exchange)
records, 378
myErrorHandler() func-
tion, 492
MyISAM table, 262
myisamchk utility, 260
EXPLAIN statement
output, 260
MySQL
access, 184-185
aggregate functions, 221
configuring, 785
continuation symbol, 185
40 7842 index 3/6/01 4:22 PM Page 840
mysql_select_db() function
841

databases
creating, 187
creating from PHP
scripts, 242
deleting, 242
results.php script,
230-231
selecting, 193-194
tables, creating,
194-199
viewing, 198-199
Web database
architecture, 228-231
date and time
converting between
PHP and MySQL for-
mats, 396-398
DATE_FORMAT()
function, 396-397
MySQL Web site, 400
UNIX_TIMESTAMP
function, 397-398
errors, 482-484
GRANT command,
188-189, 192-193
identifiers, 199-200
installing, 783
UNIX environment,
783-787
Windows environment,

793
join types, 219
logging in to, 185-187
logging out of, 193
max_connections parame-
ter, 235
mod_auth_mysql module,
322-324
documentation Web
sites, 324
installing, 322-323
mysql command, 186
privileges, 188-193
global privileges, 189
GRANT command,
188-189, 192-193
principle of least
privilege, 188
REVOKE command,
192-193
types, 190-191
resources, 806
REVOKE command,
192-193
semicolons (;), 185
syntax, extended, 222
users
GRANT command,
188-189, 192-193
REVOKE command,

192-193
setting up, 187-188,
192-193
Web site, 185
mysql command, 186
mysql connect() function,
482
mysql database, 246
columns_priv table, 250
db table, 248-249
host table, 249
tables_priv table, 250
user tables, 247
MySQL database
connection verification,
250
request verification, 251
mysql errno() function,
483
mysql error() function,
483
MySQL online manual
Web site, 206
mysql pconnect()
function, 483
mysql query() function,
483
mysql select db()
function, 483
MySQL Web site, 226,

263, 322, 784, 795, 802,
806
date and time functions,
400
online manual Web site,
206
mysqladmin facility, 199
mysql_affected_rows()
function, 241
mysql_close() function,
234
mysql_connect() function,
234
mysql_db_query()
function, 236
mysql_fetch_array()
function, 236-237
mysql_fetch_row()
function, 237
mysql_free_result()
function, 241-242
mysql_numrows()
function, 236
mysql_pconnect()
function, 234
mysql_query() function,
235-236
mysql_result() function,
237
mysql_select_db()

function, 235
40 7842 index 3/6/01 4:22 PM Page 841
naming functions
842
N
naming functions,
133-134
naming conventions,
code, 463
function names, 464
modular names, 464
variable names, 463-464
Natural Order String
Comparison Web site,
105
navigating
files, 64
within an array, 88-89
NET START MySQL
command, 794
Netscape Web site
cookie specification, 432
SSL 3.0 Specification, 347
network lookup func-
tions, 374-378
checkdnsrr(), 378
explode(), 377
gethostbyaddr(), 377
gethostbyname(), 376-377
getmxrr(), 376-378

parse_url(), 377
network services,
connecting, 484-485
New York Times Web site,
304
newbooks.txt file, 263
newline control sequence
(\n), 58
newsletters, online, 656
account settings, 689
accounts, creating,
673-675
administrative functions,
692
attachments, 658
databases, setting up, 660-
663
diagrams, 658-660
file upload, 657
HTML version, 658
list archives, viewing,
686-687
lists, creating, 693-695
lists, viewing, 679-686
logging in, 675-678
logging out, 691
login, implementing,
672-675
passwords, 689-691
plain text, 658

previewing, 702-703
requirements, 656-657
script architecture,
663-672
sending messages,
704-708
subscribing, 687-689
unsubscribing, 687-689
uploading, 695-702
next() function, 88
nl2br() function, 97
nodes (Web forum tree
structure), 713
child nodes, 714
leaf nodes, 714
parent nodes, 714
root nodes, 714
NOT NULL keyword, 196
notify password()
function, 523
null values, avoiding
(Web databases),
179-180
number_of_accounts()
function, 637
numeric column types,
201-202
floating point data types,
201-202
integral data types, 201

numerical position of sub-
strings, finding, 107-108
numerically indexed
arrays, 71-73
accessing with loops, 73
contents, accessing, 72
initializing, 71-72
O
object-oriented (OO)
development, 148-150
attributes, 148
class attributes,
152-154
creating, 151
classes, 149
creating, 150-152
designing, 158-159
instantiation, 152
constructors, 151-152
encapsulation, 148
inheritance, 150, 155-156
multiple inheritance,
157-158
overriding, 156-157
operations, 148
calling class opera-
tions, 154-155
creating, 151
polymorphism, 149-150
writing code, 159-168

attributes, 159-160
functions, 160-161
meta tags, 160
operations, 161
40 7842 index 3/6/01 4:22 PM Page 842
operators
843
Page class code listing,
161-165
ServicesPage class,
166-167
TLA Consulting home
page, generating,
165-166
ODBC (Open Database
Connectivity), functions,
242
one level up directory
symbol ( ), 359
one-to-many relationships
(databases), 175
one-to-one relationships
(databases), 175
online brochures (com-
mercial Web sites),
269-271
common pitfalls, 269-271
tracking success of sites,
270-271
online newsletters, 656

account settings, 689
accounts, creating, 673-675
administrative functions,
692
attachments, 658
databases, setting up,
660-663
diagrams, 658-660
file upload, 657
HTML version, 658
list archives, viewing,
686-687
lists, creating, 693-695
lists, viewing, 679-686
action buttons, 681-682
logging in, 675-678
logging out, 691
login, implementing,
672-675
passwords, 689-691
plain text, 658
previewing, 702-703
requirements, 656
components, 657
script architecture,
663-672
sending messages,
704-708
subscribing, 687-689
unsubscribing, 687-689

uploading, 695-698
multiple files, 698-702
OO (object-oriented)
development, 148-150
attributes, 148
class attributes,
152-154
creating, 151
classes, 149
creating, 150-152
designing, 158-159
instantiation, 152
constructors, 151-152
encapsulation, 148
inheritance, 150, 155-156
multiple inheritance,
157-158
overriding, 156-157
operations, 148
calling class opera-
tions, 154-155
creating, 151
polymorphism, 149-150
writing code, 159-168
attributes, 159-160
functions, 160-161
meta tags, 160
operations, 161
Page class code listing,
161-165

ServicesPage class,
166-167
TLA Consulting home
page, generating,
165-166
Oodie.com Web site, 805
Open Database
Connectivity (ODBC),
functions, 242
opendir() function, 359
opening files, 52
file modes, 52
fopen() function, 53-54
FTP (File Transfer
Protocol), 54-55
HTTP (Hypertext Transfer
Protocol), 55
potential problems, 55-56
OpenSSL, setting up, 788
OpenSSL Web site, 784
open_mailbox() function,
642
operating systems, data-
base security, 252
operations (object-ori-
ented development),
148, 161
calling class operations,
154-155
constructors, 151-152

creating, 151
operators, 25-33
arithmetic operators, 26
assignment operator, 22
assignment operators,
27-29
combination assign-
ment operators, 28
decrement operators,
28-29
increment operators,
28-29
40 7842 index 3/6/01 4:22 PM Page 843
operators
844
reference operator, 29
returning values, 27
associativity, 34-35
bitwise operators, 31
comma operator, 32
comparison, WHERE
clauses, 212-213
comparison operators,
29-30
equals operator, 29-30
error suppression operator,
32
execution operator, 32-33
logical operators, 30-31
precedence, 34-36

string concatenation
operator, 20-21
string operators, 27
ternary operator, 32
totaling forms, 33-34
optimizing, databases,
261-262
default values, 262
designs, 261
indexes, 262
permissions, 261
persistent connections,
262
tables, 261-262
optimizing, code, 472-473
Zend Optimizer, 473
or operator, 31
ORDER BY clause, SELECT
statement, 219
ordered data, retrieving,
219-220
ordering strings
strcasecmp() function, 105
strcmp() function, 104
strnatcmp() function, 105
orders for goods or ser-
vices (commercial Web
sites), 271-275
obstacles to potential
customers, 273-275

orders.txt file, 58
output
EXPLAIN statement, 257-
260
formatting, 592-593
SHOW GRANTS state-
ment, 255
outputting
images, 409
line graphs, script code,
405
output_fns.php, 502, 660
output_fns.php library,
630
overriding (inheritance),
156-157
owners (scripts),
identifying, 452
P
p switch (add – to front)
(mysql command), 186
Page class (object-
oriented development),
161-165
TLA Consulting home
page, generating,
165-166
page.php, 596
page.php file, 600-602
pages (Web pages),

protecting multiple
pages, 312
parameters
Apache (MaxClients), 235
drawing functions, 407
extract() function, 91
function parameters,
134-136
calling functions, 130
pass by reference,
138-139
pass by value, 139
max_connections
parameter, 235
startup, 794
parent nodes (Web forum
tree structure), 714
parse_url() function, 377
pass by reference
(function parameters),
138-139
pass by value (function
parameters), 139
passing by reference, 90
passthru() function, 366
PASSWORD() function,
311
passwords, 291-292, 499
database security, 252-253
encrypting, 252

authentication, 310-311
logging in to MySQL,
186-187
storing, 252
storing (authentication),
308-310
user authentication,
519-521
resetting, 521-526
passwords (MLM),
689-691
paths, file, 360
40 7842 index 3/6/01 4:22 PM Page 844

×