Slashdot Mirror


Beginning PHP and MySQL

norburym writes "W. Jason Gilmore and Apress have put together an impressive volume, both in girth and content, in Beginning PHP 5 and MySQL, From Novice to Professional. At first glance, it appears that any technical manual that tries to approach such heady stuff such as PHP and MySQL for an audience ranging the span from beginner to the uber-geek is headed for failure. Happily, I can report that Gilmore and Apress have given the world one book that will replace many other PHP and MySQL volumes. This is one that the reader will consistently rely on and keep near to hand." Read on for the rest of Norbury-Glaser's review. Beginning PHP and MySQL: From Novice to Professional author W. Jason Gilmore pages 800 publisher Apress rating 9 reviewer Mary Norbury-Glaser ISBN 1893115518 summary PHP and MySQL

One key to the book's success is the manner in which Gilmore approaches his subjects. The text is split neatly into three sections: the first deals exclusively with PHP and comprises the bulk of the book's content, the second section goes into depth with MySQL and the final chapters deal with PHP/MySQL integration. This layout is where the promise of appealing to such a wide range of user abilities succeeds admirably. The beginner can read cover to cover and come out of the pipe with a solid, practical knowledge of PHP, MySQL and how to combine the two to build advanced web applications. An experienced MySQL or PHP guru can skip the area of his expertise and gain much from the chapters on the other. A more advanced user can use this book as reference material, skim the chapter outline, pick and choose topics of interest and quickly find the answers they seek. Everything is cleanly written, with little or no anecdotal filler or asides. Each chapter begins with a nice overview of what will be covered and ends with a brief but concise summary.

Gilmore begins with nine chapters specific to the PHP language and its many core features and extensions, taking particular care over installation and configuration issues (platform specific instructions are included for UNIX/Linux (Mac OS X users can swim in this pool very easily) and Windows), basics (data types, variables), functions, arrays, PHP's object-oriented functionality and expressions. The next ten chapters delve deeper into PHP's file and operating system functions, web form integration, http authentication, file upload management, LDAP, session management (one of the best aspects of PHP and incredibly easy to use), Web Services (SOAP, SimpleXML extensions as well as NuSOAP and MagpieRSS -- cool stuff!), security and PHP's SQLite database extension. SQLite is an exciting multi-platform database engine that will most likely prove to be hugely popular in the near future. It's interesting to note that Apple plans to integrate SQLite into their next release of OS X, Tiger. Also of note is Gilmore's well-written chapter on PHP and LDAP. He provides an extremely competent introduction to LDAP and PHP's LDAP extension. If you work in an enterprise environment, this knowledge will become an integral part of your mindset and vocabulary.

The SQL section of the book is compact and concise. Gilmore manages to take the reader through a fast but detailed introduction to MySQL. Installation and configuration, clients (the standard set and some GUI based administration clients), table structures and security/user management are all explained with precision and an eye toward practical expectations.

Chapters 26 through 30 stand out, with an integrated approach to both PHP and SQL. This is where Gilmore pulls it all together. The reader is introduced to PHP's MySQL functionality, creating MySQL database classes, indexing and searching, transactions and importing and exporting data. There are numerous excellent real-world examples throughout this section that will enable the reader to create elegant, advanced web applications.

Gilmore removes the complexity and ambiguity inherent in many technical books and gives the reader a detailed approach to these two wildly popular open source packages. Beginning PHP 5 and MySQL will definitely serve the novice, the professional and those in between. For anyone wondering what all the fuss is about with PHP or MySQL or for anyone who has wanted that one volume that will explain it all, this is definitely the book for you. It is at once an excellent tutorial and an indispensable reference manual.

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

16 of 228 comments (clear)

  1. other training materials here... by ubiquitin · · Score: 5, Informative

    For the basics, there's an online course that I put together for an undergradute class last year here: PHP Consulting training.

    --
    http://tinyurl.com/4ny52
  2. Why MySQL? by Megaweapon · · Score: 4, Informative

    I've found PostgreSQL to be an easier database to work with and admin. When properly tuned I can't tell the difference between the two for most queries. Just my $0.02.

    --
    I'm sure "SlashdotMedia" will improve on all the wonders that Dice Holdings blessed us all with
    1. Re:Why MySQL? by arevos · · Score: 4, Insightful

      My guess is that more hosting firms offer MySQL than PostgreSQL. If I'm correct, then it would make sense for them to appeal to the wider audience.

  3. register_globals = off by Neil+Watson · · Score: 4, Informative

    I hope line one tells us to always leave register_globals = off. Better yet, I hope PHP5 always runs that way.

    1. Re:register_globals = off by Ford+Prefect · · Score: 4, Funny

      magic_quotes_gpc = On

      Switch the damn thing off. It\'s a bloody annoying hack which may (or may not be) switched on for a particular web host, meaning that for security reasons your code has to check whether it's switched on or off, and massage data accordingly. :-)

      I\'ve got two functions which automatically strip incoming data of any added escaping, because with my form validation stuff the text may either go into an SQL query or back into the form again, with missing fields highlighted. Text might have come out of the database sans escaping, for editing purposes, and I don't want to have to write my forms code to treat data differently depending on its source. If everything\'s plain, unescaped text, it makes things so much simpler...

      A couple of simple rules - firstly, when creating a database query, always (integer )$record_id or '".mysql_escape_string( $input_string )."' all variables in your queries, having previously checked them for sanity.

      Secondly, keep as much code as possible in defined functions, out of the scope of register_globals idiocy. Yes, it can be switched off, but always assume that it's switched on, and is your enemy. Plus, it's a lot easier to track incoming data in your code when it's all defined at the beginning...

      page_record_input( ACTION_EDIT, array_unescape( $_POST['input_record'] ), (integer )$_GET['record_id'] );

      And lastly, always assume that your users are out to get you. Validate all data, and assume everything and everyone is hostile. :-)

      --
      Tedious Bloggy Stuff - hooray?
  4. It's cheaper at Amazon than at BN by civilengineer · · Score: 5, Informative

    $26.39 at Amazon.com. $31.99 at BN.com

    --

    New year Resolution: Don't change sig this year
  5. Re:Switch from asp - php(5) by yohan1701 · · Score: 5, Insightful

    If you are unfamilar with linux and only want to learn php just install mysql and php on a windows box.

    The setup is pretty easy getting php send email is the most difficult part.
  6. Why MySQL? create user foo createdb; by temojen · · Score: 4, Insightful

    Creating a postgresql user who has the ability to create databases makes that user a superuser of ALL databases. This makes postgresql tricky to use in a mass virtual hosting environment.

    Also, most web applications are not written to take advantage of features such as stored procedures. This is probably partly because the developers don't understand them, and partly because MySQL is so common already.

    1. Re:Why MySQL? create user foo createdb; by Unordained · · Score: 5, Interesting

      Last I heard, the same sorts of reasons were involved in Firebird (the dbms) not being commonly available from hosting companies -- the admin side of things isn't quite geared toward hundreds of independent DBA's all on the same server and all needing to be kept out of each others' stuff. I'm pretty sure hosting companies would also want to make sure you can't load your own modules (user-defined-functions) out of fear you might load something that crashes a lot, or has nasty side-effects. Stored-procs seem safer though. Then there's managing CPU/memory/disk resources trying to make sure no single user's queries monopolize the server (particularly badly-written queries.)

      From what I've seen, people who use MySQL rarely have a good understanding of even the fundamentals of normalization, joins (all types), the difference between WHERE and HAVING, etc. -- stored procedures, constraints, domains, triggers, etc. are just entirely lost on them. They might start to see some benefits to another server system when they run into the quirks of MySQL (and particularly its data-integrity issues, silent conversions, "transactions", etc.)

      But where's my C++/Firebird book? Or my Java/PostgreSQL book? Or my Cobol/Oracle book? What we really need to figure out is how we can learn from this duo (PHP/MySQL) what makes a good set of language bindings, a good database interface, and in general a good programmer experience. I'm sure we can improve these aspects in other languages, giving ourselves more (good) options.

    2. Re:Why MySQL? create user foo createdb; by discord5 · · Score: 5, Insightful
      Creating a postgresql user who has the ability to create databases makes that user a superuser of ALL databases.

      Not jumping to the defense of postgresql or anything (although I do have to use it quite frequently), by why would want to give a user permission to create a database anyway? Most hosting companies will provide you with one database, and that's it. If you need another one, you pay extra.

      Also, most web applications are not written to take advantage of features such as stored procedures.

      So instead of stuffing their database logic where it belongs they write complicated "sql libraries" that are a pain in the behind, riddled with bugs, and eventually just make your code more complicated.

      I've been involved in a couple of projects where I had to maintain other peoples code, and I've seen bad code, really bad code, and really really bad code when it comes to databases. One project involved a database that was supposed to keep track of visa clearing, and for each step that happened in the clearing process (there were 3 if I remember correctly) a log had to be kept in the database. The original developer had a good table design but the library that did all the logging sucked bad. Somewhere he forgot to mark a 'status' field as false and in certain conditions the shit really hit the fan (read: some customers got billed twice, or too much).

      If he had taken the time to write either stored procedures for that table (over the course of the 3 years I ran that project, the table itself never needed to be altered) his code wouldn't have been such a mess, and the modifications to that project wouldn't have taken so long.

      This is probably partly because the developers don't understand them, and partly because MySQL is so common already.

      Let's not forget the most important factor in webdevelopment projects: cost. Customers want results, and they want them fast and cheap. Having to explain to a customer that you need to design a solid database before you can write a letter of code alone is more than enough excuse for that customer to go to another developer who claims he doesn't spend that much time on his database.

      Even worse, to most customers application development couldn't possibly be more complicated than Visual Basic. Webprogramming can hardly be any more difficult than drawing boxes on your screen and the program you draw those boxes in does most of the work. Explaining to people with that attitude that a solid database design will save them possible problems in the future is like banging your head against a brick wall. The wall doesn't understand what you're trying to do, and you're left with a headache at the end of the day.

  7. Stick with PHP 4 by The_Real_Nire · · Score: 5, Interesting

    As an experienced PHP programmer, I'd HIGHLY recommend coders, especially beginners, tick with PHP version 4. I know its tempting to get the 'latest and greatest', however, v5 is still too new, and the majority of servers out there still only support v4 code, so you will run into problems if you already start using functions/methods available in v5 only, and dont own/operate/have root on the server in which your code is going to run, and only ever run.

    I don't plan to make the switch to version 5 for at least 9 months or so, when v5 becomes the true de facto.

    1. Re:Stick with PHP 4 by mgkimsal2 · · Score: 5, Interesting

      This is a great point. I think/hope that PHP5 has a faster adoption rate amongst hosting companies, but it'll still take some time.

      PHP5 *does* make sense for corporate/internal developers, or anyone else writing for a more controlled environment. For average joe, however, widespread PHP5 support is still minimally months off, if not years (I hope not!)

  8. My PHP reference... by temojen · · Score: 4, Informative

    All you need.

    Includes all the functions, too. Without advertizements.

  9. Re:Books? by kfg · · Score: 5, Insightful

    . . .it seems so much easier to me to find what I'm looking for on the web.

    What you are looking for is not always what you need to know.

    KFG

  10. For those who wish to buy this book by Pugio · · Score: 4, Informative

    Cheapest price I've found is $23.52 (this includes shipping) from here. Now the question is... PHP or Perl? Which do I choose? (Old debate I know.)

  11. Problems while reading the book. by Mr_Icon · · Score: 4, Funny

    Something I've noticed: if you flip the pages too fast, they all become blank with the only message showing:

    Warning: mysql_connect(): Too many connections in /usr/hand/book.php on line 4431.

    --
    If you open yourself to the foo, You and foo become one.