Jump to ratings and reviews
Rate this book

PHP & MySQL : The Missing Manual

Rate this book
Good basic intro to the most critical PHP and MYSQL concepts.

100 pages, Paperback

First published November 18, 2011

20 people are currently reading
59 people want to read

About the author

Brett McLaughlin

39 books8 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
16 (30%)
4 stars
17 (32%)
3 stars
13 (24%)
2 stars
4 (7%)
1 star
3 (5%)
Displaying 1 - 4 of 4 reviews
Profile Image for C.
1,244 reviews1,023 followers
September 10, 2021
This intro to PHP was informative but not as engaging as Head First PHP & MySQL. It's written for those who know HTML, CSS, and some JavaScript. It uses a basic web app as the example project throughout the book, and each section builds on the previous ones. It covers a few PHP best practices, but not as many as I would've liked.

Notes follow.

PHP Syntax
$_REQUEST is an array that holds data entered into a web form by a user.
• Wrap a variable in {} to use it within a string. This doesn’t work for constants.
• Print new lines with \n.
=== denotes identity, meaning that not only do the two values evaluate to equal values, they are also of the same data type.

• PHP and SQL prefer underscores over capitalization in variable names.
$_FILES holds data about a file uploaded by a user.
• Put @ directly before a function to suppress errors.
• Reference an object's method with ->; the syntax is $object -> method().

• Use a heredoc to mark a piece of text. Start with << and end with EOD (on its own line, with no space before).
• Retrieve cookie values with the $_COOKIE superglobal.
• Use the $_SESSION superglobal when dealing with sessions.

PHP functions
trim removes whitespace; rtrim removes whitespace to the right; ltrim removes whitespace to the left.
• Use preg_match to test if a regex occurs and preg_match_all to count all occurrences.
• In most cases you want to require, not include, because you need the file to run. Use require_once unless you truly need to require something multiple times.
header sends a raw HTTP header to the browser. It must be called before any other output. header("Location: path") changes location to the specified path.

is_uploaded_file ensures that a file name references a file uploaded with HTTP.
getimagesize returns an array of info about an image, including MIME type, height, and width.
sprintf prints to a string. You construct a string using any calculations you need and pass info to sprintf.
is_null tells if something lacks a value.

crypt does one-way encryption.
setcookie sets a cookie.
empty evaluates PHP types and returns true if empty, false if not.
session_start starts a session.

PHP best practices
• Even though MySQL records only take as much space as the stored data needs, it's still good to use the proper types and lengths because they provide info about what goes in each column.
• All things being equal, it's better to store media on a file server and store the path in the database.
• Try to keep the bulk of PHP at the beginning of a script, then just insert data into HTML below it.
• Make as few function calls as you need. Use small functions with groupings or higher-level functions that assemble small functions in useful ways. Make simple calls rather than many calls.

• To log a user out, set the cookie's value to empty and expiration to a date in the past.
• There's no functional difference between $_REQUEST, $_GET, and $_POST in terms of getting request info. So, use the one that will be most clear and specific in a certain case. Use $_POST when you can, $_GET when you're getting a GET request, and $_COOKIE when you're looking for a cookie.
• Sessions are generally preferable to cookies, but you might use cookies when you need data that persists or store data that's not sensitive.
Profile Image for Jeff.
41 reviews
August 30, 2014
The most recent edition of this book is not old, but it instructs learners to use deprecated, soon-to-be-removed function calls for connecting to and/or querying an SQL db using PHP. So, in 6 months or so, millions of servers will update to PHP 5.4+, and anyone who tries to use this book to learn about PHP and MySQL will sit frustrated before a computer screen wondering, "What am I not understanding?!?" And these upcoming changes have been in the PHP documentation for several years (and *any* LAMP developer would know that).
11 reviews
August 29, 2013
I was excited when I got this book from the library, since this edition was published less than a year ago (November 2012) and hopefully would be a good resource. Sadly, this is not the case, due to the use of deprecated code throughout the book.
Displaying 1 - 4 of 4 reviews

Can't find what you're looking for?

Get help and learn more about the design.