P

padding strings, 166

printf function (PHP), 226-228 parameters (constructor methods), 98 parameters (function), 86, 89 default values in, 90 parameter references, 91

parent operator, 102 partitioning, 6 passwords storing in the database, 311 pattern matching, 329

(see also regular expressions) PCRE (Perl-compatible regular expressions), 329 PDO database abstraction, 372 PEAR (PHP Extension and Application Repository), 190-197, 371 adding packages, 192 Auth_HTTP, 301-305, 341-343 categories of modules, 190 creating connection instance with PEAR

DB, 195 database functions, 179 displaying books table (example) with

PEAR DB, 193 displaying books table (example) with

PEAR::MDB2, 196 installing PEAR, 191-192 structured libraries, 371 pear install Auth command, 302 pear install Auth_HTTP command, 302 PEAR::MDB2, 196 PECL (PHP Extension Community

Library), 371 Perl-compatible regular expressions

(PCRE), 329 permissions checking for files, 239 directories containing session data, 320 PHP, 39-61

accessing files remotely, 37 application components, 4-7 Apache web server, 5 compatibility of, 7 MySQL, 6 MySQL database, 6 PHP, 4 arrays, 107-121

array functions, 119 blog postings summary, displaying, 346-348 changing database objects from, 263-265 creating a table, 263-265 dropping a table, 265 handling errors, 265 code building blocks, 43-60 concatenation, 54 constants, 55-56

PHP (continued)

math, 57-60 strings, 50-54 variables, 43-50 coding standards, 366-370 comments, 366 control structures, 370 formatting, 367 naming guidelines, 369 objects, 369 COM, 4

comments, adding/changing (blog example), 358-364 conditionals, 71-77

connecting to MySQL database, 180, 183 database functions, 179 date and time functions, 233-237 arithmetic, 235 display formats, 234 timestamp creation with mktime, 237 validating dates with checkdate, 236 enabling on Mac OS X, 25

testing your installation, 27 error logging, 336 expressions, 62-64 file manipulation functions, 238-248 forms database query using form data, 215-217 feet-to-meters converter, 212 file handling submission of form data, 200 modifying search to process results, 201 time zone conversion utility, 212-215 frameworks, 372 functions, 45, 85-106 generating XHTML, 261 HTML text and, 39-43

adding PHP comments, 42 text output, 39-43 HTTP authentication, 288-294 validating username and password, 290 verifying username/password against database, 292 installing, 21-27

destination folder, 22 downloading latest version, 21 Installation Wizard, using, 21

on Linux, 16

restarting Apache server, 25 testing your installation, 25 manipulating database data, 266 deleting data, 277-281 displaying results with embedded links, 267-270 form to add data and process, 270-276 inserting comment into database table, 7

performing a subquery, 282-284 updating data, 276 MySQL PHP Connector, installing, 32 operators, 64-71 PEAR (see PEAR) place in web development, 2 posting and its comments, displaying

(blog example), 349-351 posts, adding and changing (blog example), 352-357 regular expressions, 332 selecting database to query, 185 separating from HTML presentation code, 218 server-side processing, 11 sessions, 294-301

.ini variables dealing with garbage collector, 300 ending, 298-301 storing in database, 301 user authentication, checking, 297 using, 295 string functions, 223-233 changing case, 231 checking for a string with strstr, 232 extracting portion of a string, 232 formatting strings for display, 224-230 length of a string, 230 system calls, calling, 249 templates, 8

sample script, 219 Smarty template engine, 9 using template to display a table, 221 using with MySQL, advantages of, 3 validation failure, redisplaying form after, 333-336 variable references, 105 XSL, 4

<?php and ?> tags, surrounding code with, 40 phpinfo function, 87 phpMyAdmin, 126-129

authentication for MySQL, 127

configuration file, 126

defining connection details for MySQL

server, 127 graphical interface, 129 installing, 126 login for MySQL, 127 objects in test database and author's table structure, 129 selecting database to administer, 128 plug-in API, 6 pointers, 119 port numbers, 321

default HTTP port, 18 position in a string, finding for a substring, 233 POST operations, data from, 318 $post_id, 355

postincrement and -decrement, 60 posting and its comments, displaying (blog example), 349-351 postings summary, displaying (blog example), 346-348 posts table (blog example), 344 posts, adding and changing (blog example), 352-357 precedence, operators, 67

PHP operators listed with precedence level, 68 predefined constants (PHP), 56 preg_ functions, 332 preg_match function, 333 preincrement and -decrement, 59 primary key, 146

importance in updates and deletions, 276 PRIMARY KEY keyword, 133 print construct, 40 printf function, 224-229

decimal point precision for numbers, 228 displaying same number in different formats, 225 formatting string, 224 padding strings, 226-228 property access operator (.), 68 property and about attributes, RDF support in XHTML 2.0, 255

quantifiers (regular expression), 331 query function, 195 querying the database basic steps in process, 180 building SQL SELECT query, 185 closing the connection, 187 connecting to MySQL database, resources for, 180

fetching and displaying results, 186 having database execute the query, 186 PEAR functions, using, 190-197 PHP functions, using, 180-190 putting it all together (example), 187-190 unions, 6

using form data, 215-217 quotation marks in data for MySQL database tables, 135 magic quotes (see magic quotes) in strings, 51

\r (carriage return) in regular expressions, 331 radio buttons (form), 205 setting up, 210

validating user input from, 210 RDBMS (Relational Database Management System), 6

realm for HTTP authentication, setting, 303

records (database), 132

redirection operator (>), 156

reference operator (&), 105

reference parameters, 91

references, variable, 105

register_globals setting, 312

reading session variables from, 314 regular expressions, 326, 329-333 anchors, 331 character classes, 332 ereg, 329

executing in PHP, 332 literals, 330 metacharacters, 330 Perl format, 332 Perl-compatible, 329 quantifiers, 331 syntax (example), 330 Relational Database Management System (RDBMS), 6

relational databases, 6, 146

MySQL, 6 relational operators, 69-71 comparison operators, 70 logical operators, 70 testing for equality or identity, 69 relationships, database, 147-148 many-to-many, 148 one-to-many, 148 one-to-one, 147 remote web server, working from, 35 RENAME command, 136 rename function, 242 REPLACE function, 169 $_REQUEST super global, 315 require function, 92

handling of missing files, 310 require statement, 94 require_once function, 92 require_once statement, 94 requiring files, 370

Resource Description Framework (RDF), support in XHTML 2.0, 255

resources used in connecting to MySQL

database, 180 web, 366, 373 restoring MySQL backup, 158 result sets, 186 RIGHT function, 168 root username (MySQL), 123 row-based replication, 6 rows (database), fetching from the result set, 186 RPAD and LPAD functions, 166 RTRIM and LTRIM functions, 167 Ruby markup support (XHTML 1.1), 254

Was this article helpful?

0 0

Post a comment