Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Posts

    5372
  • Joined

  • Last visited

  • Days Won

    154

Larry last won the day on May 18

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

Newbie

Newbie (1/14)

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

Recent Badges

435

Reputation

  1. It might be best if you start coding by documenting what you want to do and then convert those comments into code. For example: Add a record to the products table. Get the product ID for the record just added. If there are sizes, add one record to product2size for each size. This uses the product ID already fetched and the size ID, which comes from the HTML. If there are product categories, add one record to product2pcat for each category. This uses the product ID already fetched and the category ID, which comes from the HTML. So with that written out like so you can see for starters that you don't need to fetch the product ID multiple times, just once will do. You'll also see that steps 3 & 4 are parallel, not dependent upon each other (from what I can tell). But your code for step 4 includes "isset($sizeError)". I don't see why that's there. That may be why the third query isn't running? From the code and your comments it looks like the second and third queries could be executed in either order as neither depends upon the other. There's nothing particularly special about running these three queries. I think you have some logic issues. As I recommended before, if you use a slew of print statements you could see what is or is not true or happening. It's a blunt debugging tool, but it works. Another likely cause of confusion is you're using both prepared statements and non-prepared statements. That's not really a good idea, from the point of comprehension. Moreover, you're not using prepared statements for the two queries that would benefit the most from the prepared statements. By using prepared statements the second and third queries can be executed within the foreach loops, nicely.
  2. One issue I can see is that you call `$product_id = $stmt->insert_id;` a second time, but you already have the $product_id value, so that shouldn't be necessary. And there's a good chance `$stmt->insert_id` won't return anything a second time it's called, but I could be wrong about htat.
  3. Could you be more specific than "the query did not run"? Did PHP attempt to execute the query but it didn't succeed? And, if so, what was the MySQL error? Or is it not getting to that point in your code where PHP is even trying to execute the query? You may want to litter your code with print statements to see what is or isn't happening, and what values exist where.
  4. Yes, there's a typo there that's my fault--sorry!--in that you should be selecting the password from the database, too. You have that in place in your code now. From your debugging work it seems that if (password_verify($p, $row['pass'])) { is returning false. That means the problem is either with $p or with $row['pass']. I would start by registering a new user with a new password--just "password"--and testing that, just to rule out that you haven't mistakenly used the wrong password (i.e., the code is actually working properly!). I'd also print out the value of password_hash('your password') and make sure that entire value is being stored in the database (using phpMyAdmin or the like).
  5. Ah, your code uses `if define()` when it should be `if defined()`. That's what your error means: define() requires two arguments, the constant name and the value, but you're only providing one (because you meant to use defined()).
  6. Ah! Kudos for figuring it out and thanks for sharing what the cause was!
  7. 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.
  8. You're most welcome. I'm glad to hear it and thanks for posting this!
  9. 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.
  10. 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.
  11. 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?
  12. 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?
  13. 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?
  14. 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.
×
×
  • Create New...