Jump to content
Larry Ullman's Book Forums

Leaderboard

Popular Content

Showing content with the highest reputation since 04/21/20 in all areas

  1. I'm not sure I'm following exactly but just to confirm, is your server properly set up to send emails?
    1 point
  2. Thanks for the nice words! Yes, as a general security rule you don't want user-uploaded files in the web directory. It would make sense to create a new folder for each user and store their uploads in their own directory. Some OSes have limits on the number of files or folders than can be in a directory, so that's a problem you'll need to worry about should you get to a high level. To show, say, an image in the browser, you'd set the HTML src to something like image.php?id=X. The image.php script would identify the image to be served and output it. I forget if there's an example of t
    1 point
  3. Hi All, Here is my solution to Pursue exercises in CH3. I combined 4 questions into one script. If you could take a look at my code and correct if I am wrong, I would be reaaaaly appreciated! Here are the questions on the book: # 1. Change calculator.php so that it uses a constant in lieu of the hard-coded average speed of 65. # 2. Better yet, modify calculator.php so that the user can enter the average speed or select it from a list # of options. # 3. Update the output of calculator.php so that it displays the number of days and hours the trip will take, when the number of hours is g
    1 point
  4. Two primary issues, one minor: - (Minor) You call the function with echo but the function itself prints, so this is redundant. - You really should use global variables in a function, for the most part. Functions should be passed the data they need.
    1 point
  5. I'm not sure I follow exactly what you're asking but I'll try to answer as best as I can... First, a constant would be better than using a hardcoded number--65--that has no context and can easily be lost within the code. The constant allows you to "label" the value and makes it easier and more obvious to change down the line. Second, the next prompt suggests taking the average speed as user input instead of using the hardcoded number or a constant. So you'd just repeat what the calculator does with distance but for the average speed.
    1 point
  6. Thanks for the nice words! It is appreciated! Unfortunately I'm not sure what's going on with that error message. It looks like it's suggesting that there's a problem with order_contents.print_id as a PRIMARY KEY but it's not a PRIMARY KEY and there's nothing in the SQL you posted that makes it a PRIMARY KEY. I've not seen this before. I'd double-check that the created database in phpMyAdmin matches the description put forth in the book. Thanks again!
    1 point
  7. Ah, no, you can't do that. You'll need to use PHP to break the multiple selections into their single counterparts and insert each one separately.
    1 point
  8. Thanks for the question! I'm not terribly worried about this. Microsoft said they're not going to provide builds of PHP for Windows anymore. Certainly someone else will pick up the torch. Also, to me, this is more of an issue for people learning or developing on Windows. I don't have hard numbers but I assume the vast majority of servers using PHP are running Linux.
    1 point
  9. Yes, both versions are comparable with respect to validating the gender. To use the NULL coalescing operator in Script 2.4, you'd probably just write it like your version of Script 2.3 (note that you don't need the $gender = NULL in there though).
    1 point
  10. I wouldn't say that line is necessary. The $gender variable is already assigned a value before being used so assigning it a "false" value has no impact.
    1 point
  11. Thanks for the interest in more books! Much appreciated! The "PHP Advanced" book would be the logical one after "PHP & MySQL". Or the e-commerce book that Necuima recommended.
    1 point
  12. Re reading a PDF - you could have a look at: https://www.pdfparser.org/ but I have not used it. Cheers
    1 point
  13. Hi Jai, Mr Ullman has a great book on e-commerce - "Effortless E-Commerce" - 2nd edition with PHP and MySQL. Cheers
    1 point
  14. Hey Jan, Thanks for the question and for the nice words! There's really no "X hours" that apply here, as every person is different. But the "how" is really very simple and reliable across the board: 1. Find a resource to learn from (e.g., my books!). 2. Take notes as you read. 3. Try. Try. Try. It's a known thing about the mind that you'll learn better if you take notes, even if you don't ever refer to them. Not just highlight, but actually write down key thoughts somewhere. And if you refer to them later, all the better. But, no matter how much you read--either in time or n
    1 point
  15. Thanks Larry, I got it; that way these two variables $days and $days_modulus: $days = $hours / 24; $days_modulus = $days % 24; are not needed, which makes the code concise. I moved them into the 'else' conditional: } else { // $hours > 24 echo '<h1>Total Estimated Cost</h1> <p>The total cost of driving ' . $_POST['distance'] . ' miles, averaging ' . $_POST['efficiency'] . ' miles per gallon, and paying an average of $' . $_POST['gallon_price'] . ' per gallon, is $' . $cost . '. If you drive at an average of ' . $_POST['a
    1 point
×
×
  • Create New...