Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5413
  • Joined

  • Last visited

  • Days Won

    155

Everything posted by Larry

  1. What's the actual problem you're having? What errors are you seeing, if any? All that being said, there's kind of a lot of problems with that code from a design standpoint. Way too much undocumented magic going on. The dynamic fetching of specific fields is dubious.
  2. You either initialize the variables before you reference them or maybe they should be coming from an HTML form.
  3. That means your SELECT query isn't working. You'll need to run it separately on the server to see what the results are (i.e., what the error is).
  4. Sorry for the delay. I wanted to remind myself of why I did what I did...which I may now remember. Maybe! I'm still a little bit confused b/c the page numbers you reference for the "Effortless E-Commerce" book don't match up with those in the printed copy of the 2nd edition. But I think I get what's going on...by looking at the SQL commands for the second example in the "Effortless E-Commerce" book, (which is the one with "customers" and "orders" tables). Foreign keys are a (normalized) database concept, in which a column in table A represents a column from table B. There are also foreign key *constraints*, which is an aspect of the database application, enforcing the existence of a foreign key. This is what you're seeing on page 197- in the "PHP and MySQL" book. The SQL in the "Effortless E-Commerce" book has foreign keys but not foreign key constraints. There's a tip on page 193 that says you could add these. As a rule, a database must have foreign keys in order to use foreign key constraints but a database can have foreign keys without foreign key constraints. Separately, and perhaps the confusion here, MySQL will use the word "KEY" as synonymous with "INDEX". This is just saying that MySQL should index--i.e., track--the values in that column. Because, as a good rule, you should index foreign key columns. So! The reason everything seems to be behaving differently for the "Effortless E-Commerce" tables is because they don't have foreign key *constraints*. Let me know if this is still not clear or if you have any other questions (and I'll reply more promptly, I promise!).
  5. Good question! Actors have a many-to-many relationship with movies because each actor can be in multiple movies and each movie has multiple actors. A rule in this model is that each movie only has a single director, so there's a one-to-many relationship between directors and movies (although in real life some movies have more than one director these days).
  6. Well, different technologies go through trends although that tends to be more impactful to new businesses and work b/c, say, an existing PHP company/site is going to need a PHP person. We're definitely in a time wherein there's a lot of talk about server-side JavaScript. That may stay or go, though. And it's totally fine. I think all arguments about X language encouraging bad code are pretty silly. You can be a good or bad programmer in any language! Your best bet would be to look at some actual job markets, whether it's for full time jobs or freelance work, and see what they're actually looking for. I suspect you'll find no clear winner or loser. For what it's worth, generally speaking companies with existing IT departments will likely have opinions on what tech they want to hire for, but on the other hand, I work for a company that's primarily a Ruby shop and they hire more than just Ruby developers. If you're a good developer in any one language, there's potential for you to be a good developer in another. Developers understand theories and practices; languages are largely a matter of specific syntax. Finally, in my previous experience, many of the people hiring a developer for a project don't know or care what tech you use so long as you can do the job at the right price.
  7. What operating system are you using? Generally, though, I don't worry about trying email locally and just wait to test that stuff using a hosted server.
  8. You're getting this error because the $row variable doesn't have an element indexed at "description". $row comes from the stored procedure, so either there's likely a flaw in your stored procedure definition.
  9. Sure thing! If you work it backward, the title is set in the HTML HEAD, which means it's in the header file. So, due to the way includes work in PHP, the script would need to have the user information prior to including the header.
  10. The setup and population commands are in the sql.sql file in the root directory of the scripts.
  11. Just open the unordered list before the foreach loop and close it after. Then, within the loop, print $day within <li> tags instead of using break.
  12. Thanks for the question and for the nice words! I would say in terms of familiarity with the concepts, you'd be an intermediate PHP developer by the end of this book. Maybe a low-end intermediate if I'm being conservative. The main thing you'd need from there is practice and experience, which no book can give you. Just a matter of doing now!
  13. So sorry for the delayed reply! This one somehow slipped past me. Are you still confused by this/still need some insights or did you figure it out while I was daydreaming? Apologies gain for missing this!
  14. Thanks for your question! The difference between the 5th and 4th editions is somewhat minimal. The difference between the 5th and 3rd edition is significant. The difference between the 5th and 2nd edition is...oceanic! The 2nd edition is probably about 10 years old and I don't even know if PHP 5 existed then (the current version is PHP 7). So much has changed!
  15. Hmmm... I've not been in this situation before but I imagine you have three options: - Uninstall MySQL and XAMPP and then reinstall XAMPP - Try to configure XAMPP to use your existing MySQL install (I have no idea what that would entail) - Just install Apache separately and forgo XAMPP I'm not sure which is best for you, it would depend in part upon how the current MySQL install was used and whether you want the easy solution or the "interesting" one!
  16. Ah! Good question! The reason is because we don't want to assume the data will come from the form or in an unadulterated way. It'd be really easy to submit data from elsewhere to this script or to modify the form in the browser and then submit that. So these conditionals provide an extra layer of security.
  17. In answer to your question, the concise.css might have another class later on that's conflicting. Your best bet is probably to move on (CSS is hard if you don't do it fulltime and it's not critical to your learning at this point). Second to that, I'd use the developer tools in Chrome to see what CSS rules are or are not being applied.
  18. So could you confirm... - Running the "SHOW TABLES" command directly on the database returns multiple records (i.e., multiple results)? - The while loop is only executed once? - Do echo mysqli_num_rows($r) to see how many rows are in the result.
  19. That's all good info! The files should be just numbers without extensions, that's good. The next thing I'd do is run view_print.php?pid=1 directly in your browser and see the result. Hopefully you'll see a PHP error that explains what's going on.
  20. What is the HTML tag for one of the images that's not showing?
  21. Hey Jack. Right now you're literally passing the string "lid" around, which won't do anything. You should double-check how the book does it. (Separately, there's no method for A tags but that's not causing your problem.)
  22. Hey Marie. Thanks for the nice words! Truly appreciated. By PHP, I was wondering how the PHP script is encrypting the password that you're storing (e.g., using the password_hash() function). But if it's working now, maybe that's good enough!
×
×
  • Create New...