Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Databases Books Media PHP Software Programming Book Reviews IT Technology

How to Do Everything with PHP and MySQL 354

Michael J. Ross writes "When it comes to creating a dynamic Web site with data store capabilities, the site developer can choose from many technologies, including PHP and MySQL. The combination of the two is rapidly emerging as a favorite, partly because they work well together, and partly because they are both available under open-source licenses. As a result, technical book publishers are cranking out a growing number of high-priced tomes that try to cover all of the details of either technology, or both. But for the developer just getting started in either one, there is a new title that could prove more accessible: Vikram Vaswani's How to Do Everything with PHP and MySQL, published by McGraw-Hill/Osborne." Read on for the rest of Ross's review.
How to Do Everything with PHP and MySQL
author Vikram Vaswani
pages 381
publisher McGraw-Hill/Osborne
rating 7
reviewer Michael J. Ross
ISBN 0072257954
summary A tutorial on PHP and MySQL, geared to the new developer.

The publisher has a page on their Web site devoted to the book; for some reason, it lists the book as containing 400 pages, but my copy has 381. The page also has links to a table of contents and a sample chapter, namely the first one. For those readers with very slow Internet access or unstable Adobe Acrobat plug-ins installed, be aware that the sample chapter -- and even the table of contents -- are offered only as PDFs, but the two links give no warning.

Most technical publishers, for every one of their books, wisely have links to the errata and sample code, right there on each book's Web page. This is the best approach, because when readers are having difficulty getting a book's examples to work correctly, they want to be able to quickly find and download the most up-to-date sample code, as well as check the errata page for any bugs in the printed code. Unfortunately, McGraw-Hill/Osborne has their links to those two types of information in an easily-overlooked part of a menubar, using small black text on a blue background. The links are near the upper left-hand corner, and outside the content section of the Web page, where the typical reader would be seeking fruitlessly for them.

The companion Web site for the book is hosted by Vaswani's software consulting firm, Melonfire. The site has the book's table of contents (in HTML), a link to chapter 1 in PDF, a profile of the author, three full-length case studies, a feedback form, and an extensive collection of links to PHP and MySQL reference material, discussion lists, articles, and tutorials. At the end of the Introduction in the book, the author invites the reader to use that companion site for connecting with other PHP users, and sharing their thoughts on PHP and MySQL development. The site itself has no such forum, so the author probably meant the discussion lists.

The companion site also has a link to download a Zip file containing all of the sample applications from the book -- from chapters 7, 12, and 16 -- comprising nine PHP scripts, an SQL file, and a data file. The code snippets themselves do not appear to be included in the download. This shouldn't pose a difficulty for the typical reader, since few of the code snippets are long. Besides, typing them in on one's computer can help to reinforce the language syntax that one is learning, as well as decent code formatting (valuable for newbies).

The book is organized into four parts.The first of these presents the basics of PHP and MySQL, including the history and features of both technologies, as well as how to install them on Unix and Windows systems, verify the integrity of the installations, and make some critical security and configuration changes, such as changing passwords. Parts II and III cover the basics of PHP and MySQL, respectively. The fourth and final part describes how to use the two together. To that end, every chapter contains snippets of code to illustrate the ideas being described. In addition, each section is wrapped up and illustrated with a sample application. For PHP, the author shows how to build a session-based shopping cart. For MySQL, he presents a simple order-tracking system. For using PHP and MySQL together, he shows a news-publishing system.

Despite its title, the book clearly does not tell the reader how to do everything with PHP and MySQL. As the author notes in the Introduction, the book is not designed to be a complete reference for either technology, but instead intended as a tutorial for Web developers who are interested in learning how to do server-side scripting in combination with a database management system. Vaswani states that he does not assume prior knowledge of programming or database fundamentals, and that these basic concepts will be taught by example, using tutorials and realistic examples. I suspect a reader not familiar with HTML, however, could be easily baffled by the book. On the other hand, most if not all developers reading a book on PHP or MySQL are likely to already know HTML well enough to understand the output of PHP-enhanced Web pages.

One strength that this book has over many similar ones is that the author explains up front how to install PHP and MySQL, rather than relegating these topics to an appendix, or skipping them entirely. This is critical, because many programmers will find that the most challenging aspects of getting started with PHP and MySQL, are simply getting them installed and working, along with a Web server, such as Apache -- and not coding the applications themselves.

Another welcome aspect of the book is the author's enthusiasm for the technologies -- although characterizing MySQL as "quite friendly" (page 150) is a stretch. Furthermore, his explanations are clear and concise. In addition, Vaswani makes no pretense that his book has all the answers; he frequently refers the reader to URLs in the online manuals of the products, for more details. In addition, he does a nice job of illustrating the advantages of normalized database tables, and later explaining how to format query output -- an important topic omitted in many similar books.

Yet, like all books, this one is not perfect. There are a number of errors or pitfalls in the book that could confuse the reader. They range from incomplete explanations of what a user will see when running particular commands, to the sort of errata one finds in all technical books. I found over two dozen in total (there may be more). In the interests of keeping this Slashdot version of the book review close to the recommended length, I won't list all of the problems here, but will instead refer the reader to a longer version of this book review, if they are interested in those details.

Aside from its many minor flaws, I recommend this title to any programmer who wants to learn the basics of PHP and MySQL. Even though the publisher could improve their production quality, choice of binding, and Web page, the author has done a good job of clearly presenting the major points. Future editions could incorporate fixes to the errors noted in the longer version of this review, as well as better explain to the neophyte how to test/debug the code snippets. Nonetheless, the intended reader would be well served by this particular book.


Michael J. Ross is a freelance writer, computer consultant, and the editor of PristinePlanet.com's free newsletter. You can purchase How to Do Everything with PHP and MySQL from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

This discussion has been archived. No new comments can be posted.

How to Do Everything with PHP and MySQL

Comments Filter:
  • Versions (Score:3, Interesting)

    by amembleton ( 411990 ) <aembleton@bigfoo ... minus physicist> on Thursday June 30, 2005 @04:59PM (#12953645) Homepage
    Which Version of PHP does this book apply to?
    Which Version of mySQL does this book apply to?

    Specifically, does it cover PHP5?
  • by EvanED ( 569694 ) <{evaned} {at} {gmail.com}> on Thursday June 30, 2005 @05:44PM (#12954035)
    BSD is more free than GPL.

    There is not one thing that you can do under the GPL that you are not allowed to do under the BSD license, and there is quite a bit more you can do under BSD.

    That is pretty much the definition of "more free" under any definition of "free" that applies to this disucssion (e.g. is not the same as "gratis").

    Now, the questions of whether the BSD license or GPL leads to more software freedom and which license promotes free software better are up for some debate. The GPL makes sure the software STAYS free, and as such, there are very good arguments that the GPL better promotes free software, the OSS movement is better off than if everything was released BSD, etc. But this is a different matter than which license is more free. If the promotion idea is what you are thinking when you say the GPL is more free, I put to you that you need to be less sloppy with your language and say what you mean, not what sounds good.
  • by eddy the lip ( 20794 ) on Thursday June 30, 2005 @06:06PM (#12954367)

    I'm big on books for learning and reference. I like to read, and I like to read on paper. I almost always prefer to grab something from my bookshelf and flip through the index than dig through a website. And I really want to emphasize that the PHP site is not, not, not a good way to learn the language. It's great when you want to find out why something doesn't work as documented (it's probably in the reader comments), but it is entirely useless as a way to learn how to effectively use the language.

    And that's ok - that's not it's intent. All of this "you don't need a book, just go to php.net!" is really doing a disservice to those new to the language, or those that would like to actually learn good programming technique. Regarding the latter, the reader comments are generally abysmal and show the ignorance common in a (relatively) young community. For those just starting out, random access to > 3000 functions is not useful. At all.

    With that little rant out of the way, I'd love a recommendation for a PHP book similar to Thinking in Java, or Advanced Perl Programming. I've looked, but all I've found are Dick and Jane Learn PHP, or dead tree dumps of the documentation.

  • Is Mason there yet? (Score:2, Interesting)

    by otis wildflower ( 4889 ) on Thursday June 30, 2005 @06:15PM (#12954519) Homepage
    I mean, I know that apache2 support is only available in CVS, but other than that, how's it compare to php?

    I just wrote a bunch of php with PEAR DB and compared to perl it felt.. unclean.. hashes and regexes are unpleasant compared to perl, and I couldn't subclass DB cleanly since it has no constructor..

    Granted, I could get stuff done pretty quickly because php is perl-like, but there's enough stuff that seems arbitrarily different from perl to make the experience sorta yucky.
  • by loudmax ( 243935 ) on Thursday June 30, 2005 @06:24PM (#12954677) Homepage
    The combination of the two is rapidly emerging as a favorite, partly because they work well together, and partly because they are both available under open-source licenses.

    These are valid reasons for their being popular, but the reviewer left out another very important reason: both of them are really easy to learn. Whatever their shortcommings, someone with only moderate technical inclanation or experience can learn enough PHP and MySQL to have a fairly powerful site up and running in a very short amount of time.
  • by L.Bob.Rife ( 844620 ) on Thursday June 30, 2005 @06:30PM (#12954782)
    The great thing about php and mysql is that its very simple. If you already know SQL commands, and C#, then you can probably code 90% of what you need to do already. PHP accepts very generic commands that are common among a lot of languages, so there isnt much to learn. I don't know offhand how well it can scale into the really big league stuff, my php/mysql site got one million hits this month, and it handled that just fine.
  • by njcoder ( 657816 ) on Thursday June 30, 2005 @06:52PM (#12955124)
    I haven't used Toad for a while as I've been using PostgreSQL more now and haven't used Oracle in a while. So I can't compare the current versions of Toad to other products. PGAdmin3 [pgadmin.org], which installs if you install PostgreSQL on windows. Probably not as good as Toad but you can do most of the things you'd want to. Also tools like CaseStudio are good modelling tools that work with PostgreSQL. I'm still looking for a good open source data modelling tool that can reverse and forward engineer with PostgreSQL.
  • by bluGill ( 862 ) on Thursday June 30, 2005 @09:48PM (#12956658)

    If that is for historical reason you are smart. PostgreSQL has always been a better database than MySQL. Perl is the old standby for web development. However today Ruby and Python have both proven themselves better languages, in that you have a good chance of reading and understanding your code latter when you need to maintain it. Therefore I have to suggest you evaluate them both, and choose one for jobs that don't have historical reasons to use perl.

    Don't waste your time on PHP. It is better than Perl, but not by enough to be worth the pain.

  • by Lillesvin ( 797939 ) on Thursday June 30, 2005 @10:41PM (#12956989) Homepage
    Somehow I can't really make it seven fewer... I've got the same keyword thingy in firefox, but I only save like 5 keystrokes... (?)

    "http://php.net/strings" <-> "php strings" // 15 strokes less (":" is shift-. on Danish keyboards and "/" is shift-7 so 2 strokes for each of them).
    "php.net/strings" <-> "php strings" // 5 strokes less. (".net/" is 6 strokes but there's still a space between "php" and "strings" in the keyword search.)

    But yeah, keywords are great, I've got them setup for wikipedia, mysql.com/doc, php.net, discogs, apache... Everything... Thank you Mozilla-people! :)
  • by MichaelPenne ( 605299 ) on Friday July 01, 2005 @01:01AM (#12957855) Homepage
    still doesn't get PHP:-).

    By the way, some yahoo [radwin.org] is using PHP for one of the most highly trafficked sites in the world, how about that?
  • Re:You forgot... (Score:5, Interesting)

    by Osty ( 16825 ) on Friday July 01, 2005 @01:23AM (#12957976)

    They aren't the default table type, though.

    Worse than that, if the table type isn't available and you try to use it, MySQL doesn't fail. It'll happily go on, ignoring that you asked for InnoDB tables with ACID compliance, and pretend that it's actually doing something when you ask it to open/commit/rollback a transaction. This is one of those "user friendly" features that really isn't, and MySQL has a bad habit of doing crap like this. If I want a table of a certain type, and that type isn't available, the DDL should cause a failure. It shouldn't succeed silently, choosing a different table type than what I asked for.

    Not to mention the abundance of features that other database systems have, like stored procedures, triggers, views, subselects, etc. Many of those features have not yet made their way into MySQL and may not until 5.1; some have been recently added to production releases; others are still in "5.0" beta.

    Don't forget, implementing those features will make MySQL slow! Real programmers don't need them! Well, not until MySQL implements them, anyway (wait, I thought implementing them would make MySQL slow? They's gots some kind of magic that can keep MySQL fast after implementing features that'll make it slow? Well hot damn!).

    Features come and go, and I have no doubt that the MySQL developers will continue to advance MySQL until it can effectively mimic a real RDBMS. The lack of features is just an additional reason to complain about MySQL. The real reason why Those Who Know Better (tm) give them so much shit is the developers' attitudes, that they think they know so much more than development houses that have spent 20+ years researching and building real RDBMS engines (Oracle, IBM, and even Microsoft). If MySQL developers would've just said something along the lines of, "We understand the importance of foreign keys for proper referential integrity enforcement, but we have other priorities right now and want to make sure that when we do implement foreign keys that we do so in a robust and performant way," I wouldn't have ever had a problem with MySQL lacking foreign key support (just used as an example). Instead, they had an attitude like, "You don't need foreign keys. If we implemented them, they'd slow down MySQL, and besides, if you're a good enough developer you can compensate for the lack of foreign keys in your application code." That attitude earned them the scorn and distrust of anybody who knows anything about RDBMS design and usage.

  • Re:Instructions: (Score:2, Interesting)

    by Decker-Mage ( 782424 ) <brian.bartlett@gmail.com> on Friday July 01, 2005 @04:57AM (#12958786)
    Frankly I have about every editor known to man (or woman) here and Crimson has become my favorite editor for day to day use. I still like emacs (boo hiss from the Vi(M) crowd I imagine, not!), but it does the job, is light-weight, and has a price that can't be argued with.
  • Re:buy a MySQL book (Score:2, Interesting)

    by Decker-Mage ( 782424 ) <brian.bartlett@gmail.com> on Friday July 01, 2005 @05:14AM (#12958833)
    Sorry but I find MySQL user (programmer) hostile, only (somewhat SQL-92) standards compliant, somewhat fast in some instances providing you live within their SQL implementation, and more than something of a security nightmare as many default settings are idiotic, to say the least.

    Now, supposedly, all will be magically better in 5.0 when it goes gold. I'm in wait and see mode. However, as a database engineer who is totally database agnostic (heck, everything agnostic), it still needs more than a bit of work. Then that's true of most of the industry.

    Security? Standards? We don't need no stinkin' (insert here).

    To get back to the review, these books are nice but not the whole answer and I have a real problem with any book that states in the title "How to do anything with...". Sorry, but I'm not someone that restricts myself to any one toolbox when it comes to creating applications, be it on the web, the server, or the desktop. I use, simply put, the best tool for the job, period. To paraphrase, when you only have a hammer, everything looks like a nail, and that is far too true of the the IT industry. I pick the tools to suit the job at hand, not the job at hand to suit the tools, or to force fit the job to match the tools.

    PHP is nice (heck, very nice). MySQL is nice, and often speedy, but still needs more than a bit of work (although 5.0 and native XML support would make it beautiful, IMNSHO). Force-fitting everything into that paradigm is right up there with the morons that say Java can do anything, anytime, and better.

    Not that I have anything against Java (yeah, right).

It's a naive, domestic operating system without any breeding, but I think you'll be amused by its presumption.

Working...