Jump to content
Larry Ullman's Book Forums

Larry

Administrators
  • Content Count

    5157
  • Joined

  • Last visited

  • Days Won

    143

Everything posted by Larry

  1. Ah, excellent find and fix! Kudos for figuring that out and thanks for sharing the solution!
  2. Yes, you're on the right path. And the concepts are a bit confusing. Remember that cookies are sent back and forth between the server and the browser. The $_COOKIES array is populated by the browser sending cookies back to the server. On the login page, the PHP script sets the cookie which means the cookie doesn't exist when the page is first loaded (i.e., it's not sent from the browser to the server upon login submission). So the logic has to factor in that the login page DOESN'T have the cookie, despite actually setting the cookie. Conversely, the cookie exists on the logout page when the page is first loaded but is then deleted (i.e., the cookie is sent from the browser to the server when accessing the logout script). This means the logic has to factor in that the cookie DOES exist upon first running the page. It probably also helps to remember that the includes become part of the page that included them. So when login.php is run without receiving a cookie from the browser, the included file also don't receive that cookie. (In other words, the execution of the included file is not a separate request from the browser.)
  3. It looks like PayPal is now using the lowercase "verified" for the payer_status. You could switch to that or use stricmp() instead.
  4. There shouldn't be. Part of the point of paying for a web host is they should have this stuff set up and working for you.
  5. This should do it: $sql_money = "SELECT j_id, amount_invested FROM j_members WHERE j_activated = 1 LIMIT 5"; $result_money = mysqli_query($conn, $sql_money); $split = mysqli_fetch_all($result_money, MYSQLI_ASSOC); Yours wasn't working, by the way, because the query selects j_id and your code refers to $data['id'].
  6. The log file helps a lot to debug this. It doesn't look like there's anything obviously amiss, which is to say it looks like all checks are passing. I would next debug this by running your MySQL queries by hand with dummy data to make sure they're all syntactically correct. You can also write more debugging info to the log file, things like "Running the SELECT query." and "No records selected." This should help you know what lines get executed and which don't.
  7. You're running the values through escape_data(), which probably means that the incoming \n (for example) gets turned into \\n which is why nothing else works from there on. And I would just use nl2br() instead of str_replace().
  8. Working backwards, that error should be given when the page does not receive a numeric ID passed in the URL. I'd check for that first.
  9. That means your SELECT query isn't working. You'll need to run it separately on the server to see what the results are. Hint: the problem is syntactical, from "WHERE" on.
  10. Sorry to hear you're still having problems. I haven't been able to test anything yet, but I just found a version of an IPN PHP example from PayPal. The key bits are: https://github.com/paypal/ipn-code-samples/blob/master/php/PaypalIPN.php#L63-L139 Some modifications would be required (including changing self::VALID to "VERIFIED" on line 135). Let me know if you need any more details on how to adapt this.
  11. When you use mysqli_fetch_array(), you're fetching only a single record at a time. Therefore, in your loop, the $menu_row variable represents a single record. It does not represent every record. The elements within $menu_row are columns of the single record. The code you have is attempting to create ALL the navigation items once for each record in the database. This isn't what you want to do for several reasons. What you need to do here is fetch all the MySQL records first (using, say, mysql_fetch_all()). Then you'll have a multidimensional array. Then you create all the navigation items just one time, referring to the proper array element in each spot. As a debugging and learning trick, I'd recommend you get in the habit of using print_r() on your variables to see what values they have at certain points. That might help you understand better what's going on.
  12. You're definitely on the right path! The next step would be start creating additional tables. For example, you'd want a students table that maps student IDs to the student's name. That's all I'll say for now so you can continue to learn yourself, but let me know if you have more questions.
  13. You only fetched a single row, which is why you got that error. As I said previously, you need to fetch all the rows from MySQL first.
  14. Right, so as I said before, you'll want to fetch the records in order and then pull them all into an array and then use PHP to display them accordingly. So with 6 columns and under 12 items, you'd display $row[0], $row[2], $row[4], $row[6], $row[8], $row[10] in the first HTML row and then $row[1], $row[3], etc. in the second HTML row. To dynamically support additional languages in the future, you'd just need to change the logic accordingly. It'll be additionally complicated if the number of languages is not divisible by 6 (the number of columns). If you write this up and start playing with it, it should become pretty obvious pretty fast how to tweak and perfect it.
  15. Glad you got this working and thanks for letting us know. If I understand you correctly, what you'll want to do is fetch the results from MySQL in the right order and then use PHP logic to output them in the desired manner. You'd want to fetch all the results into one array and then pull from it accordingly. For example, you pull in all the rows and then output, maybe, row 0, 4, 1, 5, 2, 6, 3, 7.
  16. Awesome. I've never gone down this particular path (I don't think).
  17. Yes, yes: walking away and taking a break is the most reliable debugging technique for complex problems!
  18. Okay, that's good. Except if your header file defines the $words variable, then you can't set $page_title to $words['anything'] before the header b/c $words doesn't exist yet.
  19. Thanks for the request! Unfortunately I haven't used or looked at the authorize.net API in a while, so I'm not in a position today where I could do that. I'll see if I can make the time in the future to look into this, though, but it won't be soon. Sorry about that! If anyone else has used it recently and can share any changes, that'd be most appreciated!
  20. You can only apply CSS to HTML but you can create or reference CSS from a PHP script, yes.
  21. I'm not exactly sure what "LI" means but I assume you're referring to the login credentials. If you look at the login script, you'll see the email address and password are hardcoded: https://github.com/LarryUllman/phpvqs-5ed/blob/master/13/htdocs/login.php#L14
  22. I think we're not quite following each other here. Let's look at this logically... 1. header.html uses if (isset($page_title)) { so $page_title MUST be set in the file that includes the header and before the header is included. 2. The code you posted above does exactly that, which is great. $page_title = $words['signin']; 3. That code only works if $words is defined. There's nothing in the code you've posted that defines $words. Does your config.inc.php or MYSQL script do that? Again, this is a pretty basic logic issue and you may find that if you talk it out you might realize where the problem is.
×
×
  • Create New...