Beginning PHP and MySQL 228
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.
other training materials here... (Score:5, Informative)
Re:other training materials here... (Score:2, Insightful)
thanks to ubiquitin for the free docs.
Re:other training materials here... (Score:2)
ttyl
Farrell
Re:other training materials here... (Score:3, Interesting)
Powerful it is not. In fact, it's a fricking mess [ukuug.org]. The only thing it has going for it is that it's popular and available on almost every web host.
Re:other training materials here... (Score:2, Insightful)
Re:other training materials here... (Score:3, Interesting)
I think you missed the point of the article I linked to. You're talking mostly about the use of a language and its users. Of course a good/bad coder can write good/bad code, that's what makes them good/bad! The point, as I see it, is that PHP is really a very simple language that has been extended and hyped beyond its capacity. Of course there are places where it is well suited. Mostly simple homepages. Even Yahoo! is switching to it, but only (as I understand) as a template language. The underlying logic
Re:other training materials here... (Score:2)
Why MySQL? (Score:4, Informative)
Re:Why MySQL? (Score:5, Insightful)
Re:Why MySQL? (Score:2)
So when are people going to step back and realize, "Hey! This isn't very good?" Although with PHP 5.0 it looks like that community is trying to clean up their act, MySQL is still a steaming pile with hackish functionality tacked on top.
The string "the giant purple crayon" should never be allowed in an integer field let alone without at least a warning dammit!
Re:Why MySQL? (Score:2)
Note: select output edited for slashdot junk filter
'the giant purple crayo
Re:Why MySQL? (Score:2)
Re:Why MySQL? (Score:2)
With the tsearch2 module, you can even order results by relevance/accuracy rather than just return in row order.
Why MySQL? create user foo createdb; (Score:5, Insightful)
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.
Before I get flamed/foed (Score:2)
Re:Why MySQL? create user foo createdb; (Score:5, Interesting)
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.
Re:Why MySQL? create user foo createdb; (Score:2, Interesting)
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.)
That's funny, I generally find the opposite.
Re:Why MySQL? create user foo createdb; (Score:3, Interesting)
Amateurs can get by with minimal investment of time. Demand for simple scripting features like forums has been on the rise for years, but the demand has a low-price point. To meet this demand, a massive supply of low-end webhosting hit the market. Now the amateurs have a lot of ready-to-go PHP scripts to use and dirt-cheap webhosting. They have what they and the majority of the Inter
Re:Why MySQL? create user foo createdb; (Score:2, Funny)
On the other hand, I only feel like I have a handle on about half of the concepts you mention - care to suggest a good place for me to learn more?
Re:Why MySQL? create user foo createdb; (Score:2, Interesting)
Re:Why MySQL? create user foo createdb; (Score:2, Insightful)
Why on earth would a vhost user ever need to create databases? You create their db when you create their account, give them control over their db and they can create as many tables as their little heart desires.
Hell with namespaces it can appear like they have completely separate databases if they really need that illusion.
Re:Why MySQL? create user foo createdb; (Score:5, Insightful)
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.
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.
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.
Re:Why MySQL? create user foo createdb; (Score:2)
Regardless, as stated elsewhere, why would the general vhosted account be given either createdb or createuser privs?
Pre-set 'em up their own database + user account. Maybe even, if they're high dollar, give 'em access to a webapp which could create their own schemas within their database (only superusers can create schemas), and then they could go wild and crazy.
Switch from asp - php(5) (Score:3, Informative)
Anyone who has done the above step and can recommend this book for me? Other suggestions?
Thanks
Albert "thec" Sandberg
Re:Switch from asp - php(5) (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.Re:Switch from asp - php(5) (Score:2)
No, because MS Windows does not come with a mail server preinstalled. To get it to send email one must either install a mail server or use code that handles the SMTP connection manually (rather than the mail() function).
ASP uses the SMTP connector that comes with IIS; Apache/PHP do not come with an SMTP connector -- one must be installed separately.
Btw, I use Apache2Triad to simplify the Apache/MySQL/PHP install on MS Windows (XP). Oth
Re:IIRC (Score:2)
You need an SMTP server first... MS Windows does not come with one by default. Almost every version of *n?x has sendmail or equivalent.
Re:Switch from asp - php(5) (Score:2, Funny)
You have condolences.
Re:Switch from asp - php(5) (Score:3, Funny)
thec.org reads as follows:
Microsoft JET Database Engine error '80004005'
Unspecified error
Re:Switch from asp - php(5) (Score:3, Informative)
I've done quite a bit of both ASP and PHP. Both languages are pretty good for web development, and in a lot of ways they're comparable. However, PHP5 moves PHP in the right direction, especially in terms of object orientation and XML. And personally I think
In terms of moving from one to the other, you could probably move to intermediate PHP proficiency quickly, with just a good PHP book and a few projects to build. The two langua
I used to swear by MySQL (Score:3, Insightful)
Postgres is where it is at.
It's PostgreSQL, please (Score:2)
Postgres was the revision of Ingres; PostgreSQL was Postgres with SQL. Minor oversimplification, but good enough.
It's been PostgreSQL for years- please call it by its proper name :-)
Re:It's PostgreSQL, please (Score:2)
Re:It's PostgreSQL, please (Score:3, Informative)
Re:It's PostgreSQL, please (Score:2)
Re:It's PostgreSQL, please (Score:2)
I'm going to stick with Mys (MySQL is too long to write out all the time).
Re:I used to swear by MySQL (Score:2, Interesting)
So what separates PostgreSQL from MySQL these days?
Re:I used to swear by MySQL (Score:3, Interesting)
PostgreSQL is under a very clear license: BSD.
MySQL is under a very clear license, too: Whatever MySQL AB Feels Like Doing Right This Minute.
I do not need to repeat the earlier comments about the differences between what MySQL AB promises and what it delivers, but suffice it to say that those differences are comparable to any other sleazy proprieta
Re:I used to swear by MySQL (Score:2)
Those two pages are a great source of information. Notice how short the PostgreSQL page is? :)
What always struck me with the MySQL gotchas page was that the SQL parser and the underlying attitude of MySQL is the real problem. Everyone always brings up *features* like triggers and stored procedures when criticizing MySQL, but look at all the gotchas where it will accept invalid data and not throw an error. It will even change your table definition in subtle but important ways, still without throwing an e
Re:I used to swear by MySQL (Score:2)
Since I started using triggers, checks and functions/stored procedures when modelling my databases I can no longer understand why people use MySQL.. PostgreSQL is so much better than MySQL in every single way I can think of! Looking at the MySQL TODO-list I will take a look at it again after 5.1 is released but until then I consider it a toy. At least for applications more advanced than a personal blog..
Re:I used to swear by MySQL (Score:2)
You're telling me. For a long time, I'd been using PHP + MySQL for web-based data-entry programs for my company. (Because, well, I basically have zero budget.)
I just started playing with Postgres a few weeks ago, and it's a godsend. The databases I work with are spaghetti-piles, even after normalization, that have lots of relationships that must be maintained between tables. Foreign keys + cascades = serenity. Not to mention stored procs, triggers... for my purposes, there's
Re:I used to swear by MySQL (Score:2)
No, I'm sorry. SQLite is where 'it' is (at).
Re:I used to swear by MySQL (Score:2)
a glock
Haha, now that.. that's funny.
Re:I used to swear by MySQL (Score:2)
register_globals = off (Score:5, Informative)
Re:register_globals = off (Score:2, Informative)
magic_quote_gpc = On
For those not familiar with php, this will escape single quotes in GET/POST/COOKIE data. Helps protect the unfamiliar from things like SQL injection attacks. Once you know what you are doing they can be a bit of a pain in the ass, but for new people, it can help make your code a bit safer.
Ack! (Score:2, Informative)
magic_quotes_gpc = On
That's quotes, plural. Sorry for any confusion.
Re:register_globals = off (Score:3, Insightful)
Just Say No (Score:2)
I disagree. Your suggestion is the way the US education system tends to work - teach kids the easy way first, then teach them the right way later (and explain why the easy way is wrong).
The magic quotes feature escapes data for use in a query. There are lots of things you can be doing with data, and storing it is just one.
Also, the escaping that magic quotes does is equivalent to the addslashes function. This is a good last resort, but better options exist for many databases - for example, mysql_escape_st
Re:register_globals = off (Score:5, Funny)
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.
Re:register_globals = off (Score:2)
Re:register_globals = off (Score:2)
Re:register_globals = off (Score:2)
Yep, if your PHP guy or host tells you that you need to turn register_globals off for security reasons, you know that the twit doesn't know how to code properly. register_globals is only a security problem for badly written code. One reason that applications will use it is because it simplifies PHP3 compatibility for some uses. Of course, there shouldn't be too many PHP3 installs left now, so they should probably ph
Re:register_globals = off (Score:2)
Those things make it pretty good, in my experience.
Re:register_globals = off (Score:3, Informative)
Bull. There's no good reason to use register globals unless you don't know how to program secure applications. There's NOTHING that can be done with register_globals on that can't be done with register_globals=off, except expose slacker, lame programmers and lame applications.
Re:register_globals = off (Score:2)
Re:register_globals = off (Score:2)
That is entirely bass ackwards. If you don't know how to program properly, you should have register_globals turned off. If you do know how to code properly, then it doesn't matter if register_globals is off or on. Well written code is inherently immune to exploit of register_globals.
With the demise of PHP3, there is no reason not to write code that is compatible with register_globals off. However,
Re:register_globals = off (Score:2)
He presumably knows that given that his advice was to leave it off.
It's cheaper at Amazon than at BN (Score:5, Informative)
Re:It's cheaper at Amazon than at BN (Score:2)
Amazon has patents and BN does not, or at least I don't know of them having any and it does not really matter. This was an executive decision at
Sometimes priciples comes before price, sometimes price comes before principles.
Re:It's cheaper at Amazon than at BN (Score:3, Informative)
$25.95 + shipping, free ship with $40 order (sadly, most tech books are pricey)
Re:It's cheaper at Amazon than at BN (Score:2)
+$2.91 shipping = $28.86. Cheaper at bamm.com [booksamillion.com] with free shipping. $27.99 if you are not a club member, $25.19 if you are. And no, you don't need to accept cookies to order a book.
And even cheaper at books-a-million (Score:2)
MOD PARENT DOWN (Score:2)
Poor choice of scope? (Score:4, Interesting)
Most referrence books and advanced books assume you already have a working environment and sometimes (think Java) installing and getting everything working is the hardest part.
Once I'm passed the initial bumps though, I want a book that's aimed at advanced users, mainly because the more "beginner friendly" a book is, the lower the signal-noise ratio in the writing.
Jason
ProfQuotes [profquotes.com]
Re:Poor choice of scope? (Score:2, Insightful)
Books? (Score:2, Interesting)
Re:Books? (Score:3, Insightful)
Re:Books? (Score:3, Insightful)
Re:Books? (Score:2)
Re:Books? (Score:2, Insightful)
1) Sometimes online resources that give a comprehensive overview are hard to come by. The web usually offers more reference-oriented materials
2) I live in the boonies, and don't have broadband. Searching for information on the Internet is a slow and painful process when you're dealing with 28.8kbps connections.
3) Sometimes I just get sick of looking at the computer screen.
Re:Books? (Score:5, Insightful)
What you are looking for is not always what you need to know.
KFG
Re:Books? (Score:2)
Re:Books? (Score:2, Insightful)
To read enough about any subject to know it in depth, I'll take a book thanks. A lot of days I'm 12 hours in front of the monitors. After a while the screens start to bug my eyes - I find myself printing a lot of stuff just so I can sit back from the desk and read it off a page...
Re:Books? (Score:2, Insightful)
I find the web great for getting started on a project and for getting to a more advanced level, but it's that middle ground that a book shines. Most how-to or informational sites just don't have the helpful fluff that a book carries, sure you can assemble the same amount of info from various web sources but a book is just easier.
Plus there's just something wierd about sitting on the can with a laptop.
Re:Books? (Score:2)
The web is a different kind of tool, and important information is occasionally very difficult to find or just not there. Same applies to books.
My PHP reference... (Score:2, Informative)
http://phpbuilder.net/
All you need. Includes all the MySQL functions, too.
My PHP reference... (Score:5, Informative)
Includes all the functions, too. Without advertizements.
Re:My PHP reference... (Score:2)
And don't forget the comments!
I've found more useful information and custom functions in the comments than any other php reference website.
Stick with PHP 4 (Score:5, Interesting)
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.
Re:Stick with PHP 4 (Score:5, Interesting)
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!)
Re:Stick with PHP 4 (Score:2)
Re:Stick with PHP 4 (Score:2)
Or if you're going to be writing the next Gallery/Wordpress/etc that will be installed on every concievable 2-bit hosting outfit you certainly need to keep PHP4 around for testing. (for reference MagpieRSS [mentioned in the review] required no changes to be compatible with PHP5)
However if you a programmer with some experience, or you're interested in building a well architected sys
For those who wish to buy this book (Score:4, Informative)
More cheap/free hosting available for PHP (Score:2)
Just my $0.02. I'm not an expert in either.
Re:For those who wish to buy this book (Score:3, Informative)
PHP and MySQL are "heady"? (Score:2)
Comment removed (Score:3, Informative)
book reviews overly positive? (Score:2, Interesting)
I'm wondering if there ever was a book review on slashdot that had as a title "Don't buy this, stay clear, vaporware". I know that the general intention of book reviews is to recommend good books to others, but what about the really bad ones? Not the obvious bad ones like "Teach yourself linux in 25 minutes" or "Cooking with Penguins".
It's just that I've never seen someone say something negative in the first paragraph of the article. It just seems like authors registered a slashdot account and started pro
Problems while reading the book. (Score:5, 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.
Finally! (Score:3, Funny)
BTW: I actually plan do do something really cool: I wanna write a Web-CMS in PHP and MySQL. How does that sound, hmm?
Not sure why... (Score:3, Insightful)
Learning MySQL and PHP together is actually a great way to go, IMHO. Especially if you have some basic knowledge of C-syntax (C, Java, Javascript, Perl) and database concepts (basic SQL). Each program is only marginally useful without the other, and each can be learned quickly.
Re:ummm (Score:3, Informative)
PHP is a programming language for "web-things". MySQL is a relational database. These are two separate things. Even if you know how to access a database from a programming language, you do not necessarily know how to design a database. With a badly designed DB and a relatively small amount of data, the advantage of using a DB might mostly be vanished.
Re:ummm (Score:2)
Umm, PHP isn't a functional [wikipedia.org] language, it's an imperative language and optionally a procedural or object oriented language.
Re:php & mysql & heady? (Score:2)
Re:php & mysql & heady? (Score:2)
People with this perspective tend to be very poor programmers - no "real programmer" would assert that a programming language can be "covered in incredible detail in about a 3 page brochure."
Re:Why? Dear lord, why? (Score:2, Insightful)
This is going to be modded troll, I can just feel it - but I stand firmly behind that. I do a *lot* of PHP development - and I can't count the times that I see this "cool script" out there that does this "awesome thing". Then, I take a look at it, the entire thing is a hack job, and it's labeled "Joe's First Script".
We don't need beginners books, we need more experienced PHP devs
Re:Why? Dear lord, why? (Score:3, Insightful)
I'd guess that this ratio is further hampered by the tendency of people who can "use it correctly" to move on to, well, real programming languages.
For whatever reason, PHP just tends to not be as sexy anymore once you know what you are doing.
Re:Don't count your hits before they match (Score:3, Funny)
Ah yes; 500 PHP and MySQL books...the two I found most valuable were "Spain for Dummies" and "Zen Vegetarian Cooking."
500 seemed an excessive number to me as well, so I took the unorthodox step of actually checking the hits. Of the 301 hits I got when searching Amazon "books" for "php and mysql" there were about 30 titles actually written on the topic of php and mysql; another 30 or so were concerned with Dreamweaver MX and Macromedia MX; perhaps 30 were about web design or MacOSX or optimizing for search
Re:Don't count your hits before they match (Score:2)