Slashdot Mirror


PHP and MySQL Web Development

PHPee writes ""Learn the concepts and build the applications..." - PHP and MySQL Web Development is a well-written web developer's guide to using these open source products to create dynamic websites quickly and easily. This book covers everything you need to design, build and debug your own website from the ground up. Special attention is paid real-world issues, like database normalization and site security. Overall, a great reference for beginner and more advanced programmers alike." Read on for the rest of his review. PHP and MySQL Web Development author Luke Welling & Laura Thomson pages 896 publisher Sams rating 9/10 reviewer PHPee ISBN 0672317842 summary From hello world to e-commerce in under 900 pages...

The authors of the book (Luke Welling and Laura Thomson) do a great job of introducing new programmers to the world of PHP and MySQL. The book is divided into five sections which take the beginner programmer through many lessons in solid, secure web programming.

Part One Starting with the "PHP Crash Course," the reader quickly learns the syntax and language constructs of PHP. The following five chapters focus on topics such as arrays, string manipulation, writing functions and object-oriented PHP. This provides a solid foundation in PHP before moving on to the intricacies of MySQL. This section is very hands-on, using realistic examples, which could be expanded upon as skills progress.

Part Two The following section focuses on MySQL, starting by explaining the advantages of a relational database vs. a flat file storage system. The book assumes no knowledge of databases, explaining simple terms such as tables, columns, rows, etc. It then progresses on to the fun stuff, like designing databases for the web and normalization.

Particular attention is placed on MySQL's privilege system, including proper use of the GRANT/REVOKE commands to give/take away rights for database users. This section is quite detailed and offers a lot more information than I expected. The various column types and associated keywords are also examined in great detail, providing the reader with a solid understanding of MySQL's main features.

Part Three Part Three of the book examines the issues associated with running an e-commerce site. This section is nicely done, looking at common mistakes and how to avoid them. These include things like server security, data backups, keeping detailed logs and dealing with other threats, such as crackers, denial of service attacks and destruction of data. Authentication methods and encryption schemes are also thoroughly covered.

Part Four This section of the book expands on part one, delving into some more advanced PHP techniques, such as interacting with the file system, using network and protocol functions and generating images on the fly with the gd library.

This section also looks at PHP's powerful session functions, including using sessions with authentication and the use of cookies.

Part Five This is by far the most exciting section of the book. Here the reader is presented with seven real-world examples that utilize most of the issues presented throughout the book. These practical projects are presented in an easy to follow manner. The basic problem is presented, and then a solution is proposed. The authors take you from start to finish, outlining the database design, necessary files and functions and show you how to tie it all together. They are also very good at pointing out possible enhancements or alterations, hopefully inspiring the reader to develop their skills and create something beyond the scope of the book.

The seven projects are as follows:
  • User authentication and personalization
  • Shopping cart
  • Content management system
  • Web-based email service
  • Mailing list manager
  • Web forums
  • Generating personalized documents in PDF format


Each of the projects has a real-life application, and can easily be modified to fit the needs of almost any website. The shopping cart application is quite complete, and could serve as a basic cart as-is. The web-based email service incorporates the IMAP and POP3 protocols in an easy to understand manner. And the web forums project discusses the complexity involved in creating a threaded discussion board. It even refers to slashdot as a "fantastic example of a popular website that uses discussion boards" :)

Other info: There are a few minor typos and errors in the book, but nothing to get angry at the authors about. Most of them are quite negligible, but may still create some frustration for beginners. (For example, they make reference to a function isempty(), which does not exist in PHP. The real function is simply named empty()...) Small errors like this may create some confusion, but the errata listed on the author's website are quite helpful, yet not all-inclusive.

The appendices do a good job of showing you how to install apache, PHP and MySQL to get up and running under both Linux and Windows. The book also comes with a CD that contains a PDF version of the entire text, all code examples, and copies of PHP and MySQL so you can set up your own development environment at home.

Overall The book is targeted toward intermediate to advanced programmers, but I'd suspect it would be more useful to the beginner to intermediate group. However, the book is organized in a way that accommodates beginners and more advanced users. If you have previous programming experience, you can probably skip some of the early chapters and jump straight into the larger projects. It's a handy reference book, nonetheless. This book covers almost everything you need to know to learn how to use PHP and MySQL to create dynamic, database-driven websites in no time at all. It does an excellent job presenting some real life projects, and the emphasis on security and clean code is consistent throughout the entire book.

You can purchase PHP and MySQL Web Development from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

15 of 223 comments (clear)

  1. I Have This Book by Acidic_Diarrhea · · Score: 5, Interesting

    I got this book over a year ago and I must say that, while I enjoy it and it is well written, I would agree that it is more for an inexperienced programmer. As someone who knows a bevy of languages, the hand holding wasn't really useful and ultimately if I had a problem with PHP syntax, I didn't go to the book, I went to the PHP docs from php.net. I find the online documentation for PHP is some of the best documentation I've ever seen for a language. I did use the MySQL sections a bit just to check on syntax for MySQL commands, specifically setting up user permissions and such. This was, in part, due to the documentation provided by the MySQL people - which is a bit lacking. But the presentation of the information on MySQL was always set up as sort of a walkthrough of your typical needs. When you need to stray from this, that's when you need to consult other sources OR start guessing. I suppose I could have benefitted more from a book purely on MySQL, use the online PHP docs, and maybe save some money! Oh, one other complaint I had was that they attempted to cover some aspects of SQL but really didn't provide enough of a description to be able to 'know' SQL. And they didn't hit normalization in any effective way whatsoever but, luckily, I already know all I need to know about normalization. I guess to sum up my review: it's a good book if you are implementing something simple and don't already know how to program that well. But if you've got a large-scale LAMP project it might be best to get some standalone reference texts for each. And now, I'll suggest a few:
    Fundamentals of Database Design is a great book for learning about normalization of a database into any of the many forms.
    MySQL by Kofler is my favorite book on MySQL.
    As for a pure SQL reference, just go with O'Reilly. Have a great day!

    --
    I hate liberals. If you are a liberal, do not reply.
  2. Target market by noz · · Score: 3, Interesting

    "Overall, a great reference for beginner and more advanced programmers alike."

    I'm not a big fan of books that are targeted at both beginner and advanced programmers. Authors and publishers attempt to target their product at all available readers, but I find myself skipping chapters in some books (either early or late). What have you found?

    1. Re:Target market by hanzwurst · · Score: 2, Interesting

      I'd completely agree to you. Furthermore, I'll never understand how one can prefer printed documentation in favor of online-documentation. There are some strange people out there ;)

      This book covers almost everything you need to know to learn how to use PHP and MySQL to create dynamic, database-driven websites in no time at all.

      This disqualifies this book for me. In my opinion, there is a lack of books for advanced PHP programmers. You'll find plenty of write-your-own-webshop-in-2-mins-books, but I'd like a book covering security or performance for example. Any suggestions?

  3. Loved it... and still use it even when not using.. by gilxa1226 · · Score: 3, Interesting

    This book is great... not only as a beginning to PHP and to mySQL, but also for combining the two into an extremely useful tool. I used the book for an independent study I did my junior year of college, and I still pull it out for references even when PHP is not the language that I'm using to interface with my mySQL server. It is great and easy to read.

  4. Phpp by Anonymous+Coward++1 · · Score: 2, Interesting

    I hardly ever use perl anymore, first of all I find that phphome is amazing, a really great resource, and second, exactly what can you do with perl that you can't do with php??? Third I find it about 3X profitable to just use static pages with some basic markup.

    Now, I'll admit, I used to be rather pro-perl, but as they say, A programmer who's under 30 and uses php has no heart, and a programmer over 30 who doesn't has no brain!

    --
    Karma: Bad (mostly affected by being such an asshole)
  5. Not ready for prime time by tuxlove · · Score: 3, Interesting

    PHP is essential, but MySQL is not stable enough for a real 24x7 web service. The lack of stability of /. probably a good example of this point. And my experience at work also bears this out. We're going to greath lengths to replace all MySQL servers with something else which is actually reliable.

    Someone showed me a quote on the web that said something like, "MySQL is quite stable - I'm able to run for 100 days without restarting it!" That's hardly the definition of stable in my book. Unless you're a hobbyist, or have very few servers and can tolerate some unscheduled downtime in your service, there is no place for MySQL in a web service. Especially when you've got dozens, or even hundreds, of SQL servers. It becomes extremely burdensome to keep them all running, and to write software which is tolerant of SQL server downtime.

    1. Re:Not ready for prime time by scottyboy · · Score: 2, Interesting

      I really don't know what you are talking about - though I concede that MySQL is far from perfect, I have no problems running it 24/7 primetime, and yes, I run it on Linux *and* Solaris. It's uptime is admirable and it is fine for a medium-sized web service.

      Your "there is no place for MySQL in a web service." sounds like simple chest-beating posturing to me.

      We've had more trouble with disk burn-outs, and we've not had very many of those.

  6. IIRC, this book covers PHP 4.0. by Dthoma · · Score: 4, Interesting

    And so it's very out of date. This may go without saying, but PHP has had a lot of improvements and general tweaks made from then. Some of these tweaks may prove frustrating.

    For example, in php.ini register_globals is now set to 'Off' by default (from 4.2 onwards) instead of 'On' and if the examples in the book assume that it is turned 'On' it means that the code samples in the book will cease to work. (For example, if the book uses '$subject' as opposed to '$_POST["subject"]' they could be in for it.)

    Even assuming that the book doesn't assume that register_globals is on, there's another problem. Being of version 4.0, it won't use the get and post array variables $_GET and $_POST but rather the deprecated $HTTP_GET_VARS and $HTTP_POST_VARS.

    There are other slight differences. For example, PHP 4.0 doesn't have the functions require_once and include_once, which are useful for making sure you don't accidentally include a file more than once (brilliant for avoiding function redeclaration errors) and the output buffering could be messed up by an incorrect setting in the php.ini file (implicit_flush, if you're wondering).

    Plus it doesn't have useful string functions like strcoll and vsprintf).

    --

    Note to M1-ers: a curt but otherwise insightful message is not "Flamebait" or "Troll".

  7. Re:The Superiority of PHP over Perl by kalos · · Score: 3, Interesting
    • Outstanding database support. PHP supports virtually every DB under the sun (although Berkeley DB is missing, oddly enough.) Perl seems limited to MySQL and PostgreSQL, and its really a kludge for the later. I've heard that this will be fixed in upcoming versions of Perl though.
    • Portability. I can take PHP code off my Linux box and plop it onto an IIS server, or even one of those new Macintosh servers and have it run without having to change a single line of code. Try doing this with Perl! Its as though it was written in assembly, Perl requires that much rewriting.
    • Graphics. PHP comes with a nice little graphics library. While I wouldn't use its to code the new Doom (VB would be a better choice) its adequate for most web pages, and should be considered as a substitute for Flash for certain things. Perl lacks a graphics library of any kind.


    I'll just use 3 of your reasons for now. Perl's DBI supports every database I've ever encountered, from the aforementioned MySQL to Oracle to Cache. Sorry, but no points there.

    Other than any odd system calls where I shell out the only line of code I ever need change when moving from Linux to a Windows server (note I said Windows and not IIS.. the webserver is irrelevant) is the first line (the shebang). This is considerably easier when everything is a module but my earlier work requires less than a minute to update as well.

    Perl has ImageMagick for graphics manipulation. Available in most flavors I've had great success with it in many areas. I was looking for an image gallery script and saw millions of php ones that were horrid and decided to write my own. Took less than 15 minutes to get everything downloaded and installed and a few more to write the scripts.

    This isn't meant as a flame but your priase of php seems more likely to be a lack of understanding of Perl or just laziness.

  8. why php vs. perl? by b17bmbr · · Score: 4, Interesting
    i have been working with perl for a few years. so, a ocuple of months ago, i deccided to venture into php. plus, my school district just installed php onto their IIS (long story, freakin morons...) server. so, since i won't touch asp (whatever bastardized incarnation m$ decides this week) i figured i'd convert alot of our site to php. it has been for the most part fairly easy. but i still use alot of perl. especially for the flat file database stuff (since they won't give us even mysql).

    here's what i discovered:
    • learning php was fairly quick, very similar to perl syntax
    • perl by a mile on regex. especially the default variable kind. php needs @_ and $_ in a big way. or am i missing something? shorter syntax, easier, at least for me.
    • list() is a nice command, but i'll take @_=split(/:/$_/) any time.
    • php is the SSI that perl could have been.

    • my point is this. i use perl to process much on the back end, maybe just 'cause i am so familiar. now, i simply save all my .html as .php. i don't see php as a perl replacement, but rather two complementary technologies. by themselves each is very powerful. but don't let this dissolve into a damn war over which language. use both. my $.02.
    --
    My problem? I was perfectly gruntled, until some numbnuts came by and dissed me.
  9. This book is great by Anonymous Coward · · Score: 1, Interesting

    A few months ago, I decided that I was going to add PHP to my resume. This book is great, even for those of us who have already programmed in other languages. This book is also a great reference for MySQL, and a lot of its conversion functions for dates and passwords.
    The last couple chapters are about reinventing the wheel: writing a web forum and writing an email client. Even though there are many open source projects in these categories, the database design concepts behind the chapters is of great value.
    I'd reccomend this book to anybody of ANY skill level in programming who wishes to learn PHP and MySQL. I haven't had my copy back for a few weeks now because so many of my friends in the comp sci department here want to borrow it.

  10. Great book by fbg111 · · Score: 3, Interesting

    I was a noob PHP programmer several months ago. With this book combined with the downloadable HTML references at php.org and mysql.net, I learned it in no time. This book makes a great supplement to the official references b/c it provides a plethora of examples that demonstrate how to do certain techniques that are not always readily apparent.

    --
    Flying is easy, just throw yourself at the ground and miss. -Douglas Adams
  11. Why I Chose PHP Over Perl by egg+troll · · Score: 4, Interesting

    Recently I've had a chance to do some web design with PHP. Previously I'd used Perl because I'd heard from many people that Perl was the end all and be all of scripting languages for the web. Imagine my suprise to discover that PHP was vastly superior! I know this is a bold statement, but I have solid arguements to support it.

    Before I begin, let me just clarify something. I'm not arguing that PHP is better than Perl in all cases. There is certainly still a use
    for Perl. Also, PHP isn't perfect but it does manage to fix many of the shortcomings I've had with Perl. Here are a few of the things I've
    noticed about PHP. Finally, I'm not the most talented Perl programmer out there. I generally prefer to use the vastly superior Python, but
    can use Perl if I have to.

    * Ease of use. After about a day I had an excellent understanding of both PHP and SQL. I was able to get a stable, useable and presentable
    website up within 24 hours of reading the basics of PHP. Learning Perl took me weeks and I'm still not even as good with it as I am with PHP.
    I would definitely not recommend anyone new to programming begin with Perl.

    * The OO of PHP is excellent. In my experience, it rivals Smalltalk. We all know that Perl's OO still needs work (whether or not OO is all that great is another discussion.) Hopefully Perl will be patched up so it supports such must-have OO features like introspection, reflection, self-replication and ontological data-points.

    * Outstanding database support. PHP supports virtually every DB under the sun (although Berkeley DB is missing, oddly enough.) Perl seems limited to MySQL and PostgreSQL, and its really a kludge for the later. I've heard that this will be fixed in upcoming versions of Perl though.

    * Speed. PHP is one of the fastest languages I've ever used. While it won't be replacing assembly or C, its definitely faster than Perl in almost every case, particularly in regex which has long been Perl's strongest point. I'm sure there are cases where Perl is equal to PHP, but I can't think of any at the moment.

    * Portability. I can take PHP code off my Linux box and plop it onto an IIS server, or even one of those new Macintosh servers and have it
    run without having to change a single line of code. Try doing this with Perl! Its as though it was written in assembly, Perl requires that much rewriting.

    * Graphics. PHP comes with a nice little graphics library. While I wouldn't use its to code the new Doom (VB would be a better choice)
    its adequate for most web pages, and should be considered as a substitute for Flash for certain things. Perl lacks a graphics library of any kind.

    * Data Structures. Under PHP you can create any type of datastructure you need: Linked lists, binary trees, hash tables, queues, inverse
    Reiser-biased recursion trees, etc. Under Perl you're extremely limited in what you can do. This is because Perl isn't OO (so you can't create Node classes, for example, usefull in a linked list) and because it lacks pointers. Some of you may notice that PHP lacks pointers, but look deeper! Behind the scenes, hidden from the user pointers are used. Because of this, PHP can support complex data structures.

    Again this is just my experience. I don't mean to offend any Perl coders because Perl was an excellent language. However, in most cases it may behoove one to write the back end in PHP instead of Perl.

    Thank you and God bless,

    Egg Troll

    --

    C - A language that combines the speed of assembly with the ease of use of assembly.
  12. Postgres? by Micah · · Score: 2, Interesting

    Seems like there's tons of books on PHP and MySQL. Not to troll, but why doesn't someone release a book on PHP and PostgreSQL? It really is a better database, and does things in a somewhat more standardized way than MySQL.

    Not that I would need such a book (since I already know the combo fairly well), but I'd like to be able to recommend PG to people over MySQL, and some would find a book like this useful.

  13. Re:Two Things by CanSpice · · Score: 2, Interesting

    Yeah, but Amazon is eeeeevil and patent-hungry and BN is the white knight of buying books online!