Jump to ratings and reviews
Rate this book

Head First Series

Head First PHP & MySQL: A Brain-Friendly Guide

Rate this book
If you're ready to create web pages more complex than those you can build with HTML and CSS, Head First PHP & MySQL is the ultimate learning guide to building dynamic, database-driven websites using PHP and MySQL. Packed with real-world examples, this book teaches you all the essentials of server-side programming, from the fundamentals of PHP and MySQL coding to advanced topics such as form validation, session IDs, cookies, database queries and joins, file I/O operations, content management, and more.

Head First PHP & MySQL offers the same visually rich format that's turned every title in the Head First series into a bestseller, with plenty of exercises, quizzes, puzzles, and other interactive features to help you retain what you've learned.

Use PHP to transform static HTML pages into dynamic web sites Create and populate your own MySQL database tables, and work with data stored in files Perform sophisticated MySQL queries with joins, and refine your results with LIMIT and ORDER BY Use cookies and sessions to track visitors' login information and personalize the site for users Protect your data from SQL injection attacks Use regular expressions to validate information on forms Dynamically display text based on session info and create images on the fly Pull syndicated data from other sites using PHP and XML Throughout the book, you'll build sophisticated examples -- including a mailing list, a job board, and an online dating site -- to help you learn how to harness the power of PHP and MySQL in a variety of contexts. If you're ready to build a truly dynamic website, Head First PHP & MySQL is the ideal way to get going.

812 pages, Paperback

First published January 1, 2008

69 people are currently reading
606 people want to read

About the author

Lynn Beighley

41 books31 followers
Lynn Beighley is the author of dozens of tech books and even more articles. She's had lots of her short stories published in lots of places. She's an editor for Manning Publications and she's currently writing a YA novel that she hopes will encourage girls to try a bit of computer programming. She got an MFA a few years back. She's on twitter as @lynnbeighley and would enjoy hearing from you.

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
175 (41%)
4 stars
157 (36%)
3 stars
73 (17%)
2 stars
16 (3%)
1 star
5 (1%)
Displaying 1 - 23 of 23 reviews
Profile Image for C.
1,227 reviews1,023 followers
September 9, 2021
I build websites with WordPress, and currently focus on front-end development (HTML and CSS). I’ve tweaked PHP, but I want to get better at modifying WordPress themes and plugins, which requires working with PHP and MySQL. This book was very helpful, as it includes step-by-step examples of building simple web applications with PHP and MySQL, and covers database fundamentals. The book is visual and easy to understand, explaining concepts and providing practical application. Like other Head First books, it’s full of quirky pictures and cartoons.

PHP
Loops
while loop: repeat code while a condition is met.
for each loop: loop through an array one element at a time, without using a test condition.
for loop: loop based on a specific number of iterations, using a counter and test condition.

Strings
• Use trim() and mysqli_real_escape_string() to prevent SQL injection.
explode() breaks a string apart into an array of substrings.
implode() builds a string out of an array of strings.
str_replace() replaces text in a string.
substr() extracts part of a string.
preg_match() checks if a string matches a regular expression.
preg_replace() replaces a substring based on a regular expression.
strip_tags() removes HTML tags from a string.

Miscellaneous PHP
• Pay attention to operand order with && (and) and II (or), because those operators are short-circuited whenever possible; if the first operand can determine the expression’s outcome, the second operand is ignored.
• Single-quoted strings aren’t processed by PHP; double-quoted strings are.

isset() checks if a variable exists.
empty() checks if a variable has contents.

• Include files: require_once() results in an error if an include file is missing, and it prevents files from being included more than once. include doesn’t do these.
• Put an @ in front of any PHP function to suppress error reporting.
• Use the ternary operator to simplify if-else statements: text expression ? statement 1 : statement 2.
• Use a switch statement with cases to execute different code depending on a value.

rand() returns a random integer.
simplexml_load_file() loads an XML file from a URL and makes the data accessible through an object.
mysqli_error() outputs error messages.

MySQL
• Use AS to establish an alias.
• Use LIMIT to limit the number of rows returned by a query.
• Use the principle of least privilege. Create users and set specific privileges and table access.
Profile Image for Ed Limonov.
13 reviews
October 11, 2019
A good book to read for any coder. The ratio of time spnet reading vs. writing is well over 10:1.
Profile Image for Josh StJohn.
11 reviews1 follower
August 20, 2010
After staring for what seemed like hours at the bookstore trying to figure out what PHP/MySQL book to buy, I found this gem. It is written in a way that is very easy to understand. The author gives you the information, then you're asked to use what you've learned to solve a problem you may encounter as a developer. The situations the author puts in front of you are always humorous, and I thought it was great that I was actually laughing quite a bit while learning something that could be very complicated and irritating.

After going through all of the lessons, I felt completely comfortable enough with PHP and MySQL to go ahead and start looking up more information online, and the author points you in the right direction of how to do that at the end of the book.

I would recommend this book to those that are interested in going beyond HTML/CSS and Javascript, but haven't done much PHP/MySQL work. If you've been coding PHP for a couple of years - I'd find something more advanced if you're wanting a "refresher".

Thanks to this book I have gone on and built complete web applications including an auction system, many content management systems, e-commerce sites, and more.
Profile Image for Jocelyn.
85 reviews4 followers
July 7, 2011
The 'head first' series has a way of explaining computer language so that it does not seem so daunting. The photographs, exercises, and diagrams truly helped me grasp heavy concepts in record-breaking time. That being said, I'm only a beginner in the language. It definitely didn't hold my hand on everything (such as using the programs it told me to install in my computer) but I suppose that can be expected. By use of the internet there are so many free videos and tutorials online that it was not very challenging. The book even has a website to download the source code for your computer. This book gets a 4 out of 5 because I feel as though more features and built in functions of the languages could have been explained. This is a great buy for a beginner, especially if you are evaluating whether programming web apps using these languages is for you.
Profile Image for Zlatan.
9 reviews1 follower
October 19, 2010
want to know how it's like to enjoy every minute of a book you're reading? Well, this book is just the right for you then. You'll learn php and mysql in no time, and have loads of fun while you're at it :)
Profile Image for David.
7 reviews2 followers
October 22, 2014
Great book if you are first getting into php/mysql coming from a non-programming background
Profile Image for Luan Borelli.
3 reviews6 followers
January 11, 2018
The book presents a differentiated didactics, full of stories and illustrations. Probably a good choice to introduce programming to new entrants in the area or even to a younger audience.

I would not recommend this book for those who already have considerable experience in the area, on the grounds that there are several other more objective bibliographic options on the subject that allow a more direct and in-depth learning.
2 reviews
August 9, 2017
This is an amazing book! Just couldn't be better! Definitely recommend to everyone.
42 reviews
April 23, 2024
The book was interesting and provided many valuable insights. It was overall an easy read. I used this as a guide while building the website https://sobd.ru
Profile Image for Jim Metzger.
4 reviews2 followers
November 27, 2013
If I see a Head First book related to something I am trying to learn or improve my knowledge on, I will pick it up and use it. Their approach to literally diving into a subject works for me. You write code as you go along as well as take part in crossword puzzles and other challenges. It sounds juvenile at first, but even for the seasoned geek, it makes learning even more fun!

I have been dabbling in PHP for years and this book put together PHP with MySQL perfectly!

Definitely 5 stars for the novice as well as for the need a better grasp professional.
Profile Image for Vincent.
63 reviews3 followers
December 29, 2014
This is a very unusual and unconventional book in its design. I suppose its design is intended to make things easier to learn, the way images and visualizations are aggressively used. I didn't end up using the book in a linear fashion, but there were some areas that I found useful, like the part detailing regular expressions, which none of my other PHP books had content on. If you're learning PHP on you're own, it's a decent alternate book that you can use as a reference as it has some unique topics, but I wouldn't use it as a primary learning tool.
Profile Image for Marc.
127 reviews4 followers
Read
October 24, 2013
This was abandoned, not because it wasn't good or useful, but because I started a PHP course and it lost its usefulness for me. I would recommend it to others as a thoughtful and fun PHP & MySQL tutorial.
Profile Image for Rohit Mishra.
15 reviews7 followers
March 16, 2011
Another winner in the Head First series. The book teaches you basic PHP in a simple manner and continues the simplicity and easy readability that is a trademark of the original HF Java.
Profile Image for Aadam.
3 reviews28 followers
May 28, 2016
I enjoyed it a lot, just like every book in the series. I read it very quickly because I had to work on a project and just wanted the basic info on the PHP and MySQL but it was really fun
Profile Image for Alyse.
146 reviews3 followers
November 19, 2016
This was for my database class. Probably the most interesting textbook. Only because it had me make a website about alien abductions....
Displaying 1 - 23 of 23 reviews

Can't find what you're looking for?

Get help and learn more about the design.