Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5394
  • Joined

  • Last visited

  • Days Won

    154

Larry last won the day on May 18 2021

Larry had the most liked content!

About Larry

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Larry's Achievements

Apprentice

Apprentice (3/14)

  • Dedicated Rare
  • First Post Rare
  • Collaborator Rare
  • Posting Machine Rare
  • Week One Done Rare

Recent Badges

435

Reputation

  1. Hey! Good questions here! For question 1, there are two facets. First, the database needs to store the product+size+price combination, which is already supported. (I forget if the admin interface allows you to set different prices for different sizes or not.) Second, on the client-side (in the browser), you'll need to use JavaScript to make the magic happen. You'd use an event handler to watch for size changes and then update the price HTML accordingly. I think I'd be inclined to have the PHP script pull all the sizes and prices first, and store these in a JavaScript object. Then, when the size changes, the JavaScript uses that object to update the HTML. For question 2, with the current database structure you'd add a colors table and then a color column to the database, so you create a new SKU for each color. Hope that helps but let me know if you have additional questions.
  2. (Resolved over email...) The publisher has PPT slides available; there aren't sample tests or homework assignments.
  3. You've already done all the hard work. Kudos! You have the values you need, as an associative array. All you need to do now is pop those values into an INSERT query, something like $arr = json_decode($json, true); if (!empty($arr['isbn'])) { // Basic validation that data was returned... INSERT INTO books (ISBN, title) VALUES ('{$arr['isbn']}', '{$arr['title']}'); Although it'd be best if you use prepared statements or somehow sanitized the values before using them in the query.
  4. If you're concerned about a fake ID scenario AND such a query not affecting any rows is cause to stop execution of the code, you could run a SELECT query using the ID first to validate that it's real before running the UPDATE. That being said, doing all that seems to me like adding extra overhead to "solve" a problem that's not really a problem. The UPDATE query, like on a password change, should use the primary key, which is immutable, and therefore not user-provided. It's unclear how a fake ID would get into the mix.
  5. Thanks so much for the nice words! I really appreciate it. This is an excellent question! What you can do is just use mysqli_query() as the conditional. The function returns a false value if it didn't run (i.e., there's an error), which is a different thing than the query running but not affecting a change. https://www.php.net/manual/en/mysqli.query.php
  6. Thanks for your interest and sorry for the delayed reply. Right now there's no plan to update the PHP Advanced book. I've not even spoken with the publisher about it. Thanks again, though, for asking!
  7. If you just google "xampp mail server windows" you'll find plenty of tutorials on the subject. (I don't have XAMPP on Windows, so I don't know off the top of my head.)
  8. From there error messages, you have two issues to resolve. The first is you haven't configured a local mail server. The second is your error handling script still references the $e_vars variable, which it no longer has defined as an argument.
  9. There are two issues here. One is that there's an error going on in the script. The second is the error handling isn't working properly. For the latter, you don't mention what version of PHP you're using, but I expect the warning in the box applies: https://www.php.net/manual/en/function.set-error-handler.php Remove the last parameter from the my_error_handler() definition, as well as the use of that $e_vars variable within it. Once you fix that, you should properly see the actual error that's happening on the page.
  10. Glad that's working for you and thanks for letting me know about the emails. I'll look into it. Cheers!
  11. My inclination is it's either not being stored or retrieved in a format that PHP can use. I'd check/confirm your column type. Also, it's best not to use "Date" as a column name since it's also a keyword in MySQL. That being said, I'd have MySQL return the data in the format you want, rather than ask PHP to convert it.
  12. Hey Max. Kudos for figuring it out and thanks for sharing the solution. The first thought that came to my mind would be to store the coordinates in separate columns. In other words, split the coordinates upon receipt and then store them in two columns. That'll make future work easier to do.
  13. Hey Nick, are you setting a "from" address when you send the email? Also, it may help if you use placeholder values when describing the problem here. I'm not 100% sure I understand the distinctions you're trying to make (e.g., sending the email to me vs receiving an email or all the uses of "me").
×
×
  • Create New...