Saturday, April 7, 2018

My book review of Murach's PHP and MySQL third edition by Joel Murach and Ray Harris

Murach’s PHP and MySQL third edition


My book review


I wish to present my review of the book entitled PHP and MySQL 3rd edition. This book was sent to me for review by Murach publishers in California.


The first thing that I wish to say is that if I could describe this book in one word, it would be “comprehensive”. The book certainly covers all the bases regarding this topic. In my experience PHP can be a vast topic and it is not the nicest of languages of languages to work with. But it is the most widely used technology for developing database driven web sites so a good working knowledge of it is essential to working on the internet.


In the following paragraphs I will present my thoughts on this book. I will not go through it on a page by page basis which I tended to do in the past, but instead I will go through chapter by chapter and pick out the more salient points.


Section 1 Get started fast with PHP and MySQL


Chapter 1 Introduction to PHP and web development with PHP


This chapter provided a good introduction to PHP web development. Your examples worked well. I did not use Netbeans but used Microsoft Studio Code as my editor. It has PHP auto complete built in.


It was soon obvious that this is NOT a book for beginners. Anybody completely new to web development would soon get lost here.


Chapter 2 How to code a PHP application


This chapter did a good job of explaining the essentials of PHP such as variables and IF statements etc.


Chapter 3 Introduction to relational databases and MySQL


This chapter did give a good overview of relational databases work and how MySQL and PHPMyAdmin operates.


Chapter 4 How to use PHP with a MySQL database


The author did a good job of explaining PDO which can be quite tricky to get ones head around.


Chapter 5 How to use the MVC pattern to organise your code


This was the first time that I read about the MVC pattern and actually understood it. I have struggled to understand this in the past and your example worked very well.




Chapter 6 How to test and debug a PHP application


I must admit that I just skipped this chapter as I find that debugging is just a matter of practice.


Overview


Section 1 presented a good introduction to the use of PHP and MySQL. I got my head around it easily enough. But this is really only a book for an intermediate of advanced programmer. A complete newcomer would clearly be lost here.




Section 2 Master PHP programming


Chapter 7 How to work with form data.


I thought your explanation of working with form data was very clear.


It was important to learn about how to guard against XSS attacks!


It was also a first for me to learn about a list box name ending in [] if you want multiple items to be selected!


I can see where the htmlspecialchars() function is vital to guard against XSS attacks!


I found that working with line breaks was useful.


Chapter 8 How to code control statements.


I am familiar with using conditionals but learning about type coercion and the “===” operator was new to me.


The switch statement on page 249 was certainly complicated!


Chapter 9 How to work with strings and numbers


At first I could not get the HEREDOC function to work. I later realised that I was using an older version of PHP, but when I switched over to PHP 7.0 things worked OK.


After that, all the examples worked well once I typed them in and ran them.


Chapter 10 How to work with dates


Your examples on page 295 all worked well.


Your examples on page 297 all worked well but I noticed a couple of oddities.


$expires = mktime(13, 30, 0, 15, 15, 2018);


still recorded a timestamp, even though there is no 15th month.


$expires = mktime(13, 30, 0, 17);


still recorded a timestamp, even though there is no 17th month.


This could just be a quirk of PHP?


Absolute and relative templates were new to me.


Pages 304 – 305 How to use the DateInterval class


All the examples here worked well but I did find these pages a bit confusing.

For the rest of the chapter, all the date examples worked well. I can certainly see where dates can get very complicated in PHP.


Chapter 11 How to create and use arrays


A discovered a problem with your first two examples on page 325.


Instead of getting a result of:


  • 7.75

  • 8.25

  • 8.875

I got:


  • $rate

  • $rate

  • $rate

For the second example I got an output of:


  • $state($rate)

  • $state($rate)

  • $state($rate)


I am not sure just what is going on here. The third example on the page worked well.


For the rest of the chapter, all your examples worked well. Things did get complicated

In places. I had never heard of a jagged array before and I am not sure where you would use one.


The task List Manager program at the end of the chapter was great to work with. But I can see where a database might be better in an application like this.


Chapter 12 How to work with cookies and sessions


Generally speaking this chapter provided a good explanation of the concepts and practices involving cookies and sessions.


All your examples worked well.


Chapter 13 How to create and use functions


Again you did a goof job of explaining functions. All the examples up to page 400 worked well. Some of the things after page 400 were more complicated and did not seem to make much sense at first, but when I typed them in and saw how they worked, things made more sense.


I am not sure about anonymous functions though. Just where would you use them?


The Shopping Cart application at the end of the chapter worked well.


Chapter 14 How to create and use objects


The start of this chapter gave a good overview of the concept of classes.


I read through the rest of this chapter and tried to understand it as best I could. I do admit that in places, this subject did go over my head.


I have struggled with this subject in the past and have had to look to other sources to try and understand it.


Your example at the end worked very well.


Chapter 15 How to use regular expressions, handle exceptions, and validate a database


I found in this chapter that all your examples worked well. But again, things did get very complicated here. Validation is important, but in PHP it certainly gets very technical and hard to understand at times.


Both the examples at the end of the chapter great to work with.


Overview


I am quite familiar with arrays, dates etc. But obviously things change over time and it is important to keep up with these changes and this section did a fine job of detailing these aspects of PHP programming. I do still struggle with objects but I am sure I will get better at them with practice.





Section 3 Master MySQL programming


Chapter 16 How to design a database


I am familiar with database design theory. I have worked with databases in the past. I though that this chapter gave a good theoretical overview of how to design a relational database.


Chapter 17 How to use SQL to create a database


I found this a very comprehensive study about using SQL to create a database. This chapter was very detailed.


I manually entered the data at the end and it all worked very well.


Chapter 18 How to use SQL to work with data.


I am familiar with SQL. However, using sub queries was new to me. I think that I will avoid them if I can.


Chapter 19 Professional PHP for working with MySQL


This chapter gave a good overview of working with PDO and MySqli.


I learned a few new things like quote() to provide security and exec() to execute the statement.


I am familiar with prepared statements but some of the methods were new.


I am not sure about the value of the “?” parameter.

The error expression operator was new to me, as well as using single quotes to guard against injection attacks.


At first I was not sure what the mysql-stmt object was all about. I think that I may have this confused with the mysqli-stmet class.


Things can certainly get complicated with PHP and MySQL!!!


Chapter 20 A database-driven web site


Page 660 – How to add HTML tags to a text file.


I was fascinated to see how PHP can take a text file and add HTML tags to it.


I have had issues using text files in a database in the past.


I noticed that you used two examples here and they both worked well.


It was very interesting to see how you use the files in the UTIL folder to get your various paths.


Both the examples that you provided worked well. Although I noticed that when I clicked on Brass and Keyboards, a picture of a guitar came up!


When I clicked on Woodwind, I got drum sets!


When I added my own category of shirts, add added my own data and images, the correct

information came up.


Obviously the database needed rearranging.


It is obvious that a content management system can be complicated but it was great that you showed how to do it properly.


Overview


Obviously MySQL is a big topic in itself. These chapters explained it well.

Section 4 Master the advanced skills for building websites


Chapter 21 How to create secure websites


It was interesting to learn about SSL and TLS layers and you provided a good explanation about how SSL authentication works.


Digital Certificates were new to me. As for storing and validating a password, I found it interesting typing in the 60 digit algorithm in your example, which actually worked quite well.


As for the two examples that you provided, I could not get either of them to work when I tried to use them.


I have to say that this chapter got complicated in places, particularly the study on cryptography. But it is good to know that this will be there when I come to develop my own website.


Chapter 22 How to send email


I must admit that I just read through this chapter and did not try any examples. It is good to know that this feature can be added to the website if it needs to be.


Chapter 23 How to work with files, uploads and images


I tried all the examples in this chapter and everything worked very well. It was pleasing to see that the image upload program worked very well.


It was amazing to see how to resize images and work with transparency, although I would

have thought that this was something that you left to your image editor.


Chapter 24 An e Commerce website.


Finally we come to the conclusion. This was not an actual full blown e-commerce website.

But it did tie everything together just nicely.


Overview


Some of this was very new to me and clearly having knowledge of such things as working with images and text files certainly extends your reach as a web site developer.



Summary


I was quite impressed by this book. The authors certainly covered all the bases. This was the first time I have been able to read a full blown PHP book like this from cover to cover and actually enjoyed it! That certainly says something about this book as PHP is not the easiest or nicest language out there.


I am not planning on building a PHP website any time soon, but if I decide to do so, this book will definitely be my reference. I would certainly recommend the book to anybody

who is serious about using PHP as their web development language.


Do I have any criticism’s of the book? Not really! I admit that I struggled in a couple of places, but we must keep in mind that this is a book for the intermediate to advanced developer and not for the beginner.


To finish up, I must say thank you once again to all the good folk at Murach publishing for allowing me to review this work. While it was a bit of a chore getting through the book, I feel that I have gained tremendously from it and I will definitely use it if I come to developing a new PHP website.


Thank you and best wishes for the future


Gerard Gates









Funeral of an old friend

This week, my good friend Colin Pilcher passed away after a fall at his home. I have known Colin for more than 40 years and it was sad to se...