Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Larry

  1. Ah! Kudos for figuring it out and thanks for sharing what the cause was!
  2. Thanks for the nice words. Yeesh on this error message, though! That command creates four keys (or indexes): on user_id, on username, on email, and on the combination of username and pass. None of those seems to be 100 bytes! My hunch is it's the login key that's causing the problem. Try removing that from the command (and delete the comma after `UNIQUE (email)` and try it again.
  3. You're most welcome. I'm glad to hear it and thanks for posting this!
  4. Aside from the use of a cookie, the sessions are an entirely server-side thing, and the method in the book just uses a different cookie. I can't imagine this is messing up Google Analytics. How do you know you can't reach Step 3 without Step 2? Keep in mind that even if Step 3 checks that Step 2 happened and reports an error message if it didn't, that still counts as a page view for Step 3.
  5. Yeah...sometimes with free things you get what you pay for! There are alternatives, though, such as: https://rapidapi.com/apidojo/api/yahoo-finance1 That requires signing up for an account and using their SDK. Offhand I don't know of a free comparable to the Yahoo! Finance API.
  6. Ah, right. Sorry for the confusion and my mistake. Chapters 12 & 13 are the only ones that interact with a database. Chapter 12 has a script that creates the database. Chapter 13 has a single CREATE TABLE command, which is in the book. That's why there's no dedicated SQL file in the download. With 20+ books, I had forgotten which books had what. But the download contains a README file and 13 folders of scripts. There's more than just the .DS_STORE file, correct?
  7. Thanks for all the info. This is almost certainly a CSS issue, although there's a small chance there's an HTML problem. Most likely the path to your CSS file is incorrect. What URL are you using for your site? And where did you put the CSS files? And what paths are you using for your CSS files?
  8. Ugh, this is an annoying type of problem! Basically HTML QuickForm can't find the resources it needs, which either means they weren't installed OR they were installed but HTML QuickForm can't find them. If it's the latter, that's normally b/c the files weren't installed in the right location OR PHP isn't looking in the right location. What steps did you take to install HTML QuickForm?
  9. There's no SQL in the .DS_STORE file. That's a remnant from the Mac OS. You can ignore it. All of the SQL commands are found in files with a .sql extension.
  10. Ah, kudos for figuring it out and thanks for sharing your journey with us!
  11. Unfortunately I don't have any experience with IIS rewrite rules. Perhaps this is something your professor could help with? If you're having this problem, certainly other people in the class will be, too.
  12. 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
  13. Glad it's working and thanks for letting us know. If you have any additional questions or problems with this particular issue, post them in this thread. If it's a new concern, a new thread works. Also, while oversharing details is better than undersharing, I don't think anyone's going to download and look through a folder of code. Best just to put all the context in the post itself. Good luck with your class!
  14. The general site resources--images and such--are referenced in the header file, so the HTML there needs to be correct. In your case, they need to start with the "/homework/ex2/html/ " bit. The HTML for images for specific products is created by the PHP scripts, like shop.php and browse.php. You need to make sure those scripts are outputting the correct HTML, including the "/homework/ex2/html/". As a debugging tip, if your dark_roast.jpg image is in the "<webroot>/homework/ex2/html/products" folder on your computer, the proper HTML reference to that image is "/homework/ex2/html
  15. I'm not sure what you mean by "secondary links" but if you're seeing broken images, the HTML references to those images are likely incorrect. The image should not be affected by any rewrite rules. What is the URL you're using to test locally (for a page that works)? What HTML are you using for one of the links that's broken? Where are the images stored locally?
  16. This is a common issue when first starting with sessions. It'll take a bit of debugging work to figure out where the problem is. Often the cause is inconsistent subdomains--www.example.com to example.com--but if you weren't having a problem with cookies, this isn't likely the cause. Working this backwards and looking at the code, here's the key bit of loggedin.php: session_start(); // Start the session. // If no session value is present, redirect the user: if (!isset($_SESSION['user_id'])) { So you're _only_ going to be redirected if there is no stored $_SESSION['user_id'] value.
  17. Oh, ah, sorry for confusion! You could name it anything in the URL; it could be "chuck=57". It's the PHP code that then uses this value and knows what to do with it (i.e., you the programmer make the correct association). It's not a big deal in this case but generally you don't want to reveal database details publicly. Hence, "id" is ever marginally more generic than using "user_id".
  18. 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.
  19. You've missed the initial double quote for the href value, which could be the cause of this. Debugging this is pretty straightforward and you've been doing good detective work. The error you're seeing is b/c either $_GET['id'] or $_POST['id'] isn't set or isn't numeric. The first time the page is loaded is a GET request, so you can ignore the POST bit. So now you can check whether there is a *numeric* id value passed in the URL. Assuming you're testing the script/code you think you're testing, the ONLY possible explanation is that there's not $_GET['id'] or there is one but it's not nume
  20. 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.
  21. Thanks for the nice words and for the interest in my books. It is appreciated! I discuss PDO in my PHP Advanced book, however that was last published in 2013 and I'm sure I didn't cover all the functions. Since you're already using PHP, maybe try giving the PHP manual a go first?
  • Create New...