Jump to content

requinix

Administrators
  • Posts

    15,266
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by requinix

  1. Obviously it isn't real code someone would write. Not all of it. But that last line, that's something one could reasonably write in some circumstance.
  2. Yes, that describes how one pre-increment operation works on a variable. That page does not explain how one or more pre- or post-increment operators on the same variable work when in the same expression. The concept is called a sequence point. Look into it: most everything you'll find will talk about C/C++, but it applies to PHP as well.
  3. Not necessarily. PHP makes no promise that the $i on the right happens before or after the ++$i on the left.
  4. That's right: .htaccess URL rewriting only tells Apache how to understand the new friendly URL structures. It doesn't also update the links on your pages for you.
  5. I suggest that you try to describe your situation and your problem to us so we don't have to try to jump into the middle of it...
  6. Check your error logs in case something happened. Also try setting up and submitting an HTML form to see how the script reacts.
  7. 500 error? Go to the error log. 500 error? Go to the error log. 500 error? Go to the error log.
  8. Do you need a full user authentication system with registration and login and all that? Or will you be granting access to a fairly small number of people that is unlikely to change? Because if you're using Apache (you probably are) then there's a stupid easy way to do this using its built-in HTTP Basic authentication.
  9. It's generally not good design if you have to pull a path like that dynamically. A script sending the email should simply write the required /LifeSaverHTML/Details/20 or whatever directly. By the way, dirname on the REQUEST_URI can be very easily fooled. Definitely don't do that.
  10. If you've already added some custom CSS for stuff then you might as well add some more custom CSS to deal with this...
  11. https://www.php.net/manual/en/migration70.php https://www.php.net/manual/en/migration71.php https://www.php.net/manual/en/migration72.php https://www.php.net/manual/en/migration73.php https://www.php.net/manual/en/migration74.php
  12. Yeah. I got that.
  13. This is something that should be solved on the webpage itself, not from within PHP. Specifically, solved with CSS. Which is why I've moved this thread into the CSS forum. I don't suppose this website is publicly viewable, is it? That would make it much easier to give suggestions on what to do... Screenshot of what it looks like? Do you have any custom CSS already applied to the site?
  14. It's not about the checkbox being checked. The problem is that the $stmt3 query returned a row, you read it, and that you didn't finish reading until it was done. Unbuffered statements (which you are apparently using) must be fully read from before you can start another query, and "fully read from" means you don't just read the one row you were expecting but you keep going until you don't get any more rows. But the solution here isn't to do that. The whole point of prepared statements is that you only need to do one of them. Preparing the same statement over and over again inside a loop is the exact opposite of how it should be used. Prepared statements should be prepared once, have their input variables set up once, and then what you repeat in a loop is setting the variables to some new values and executing the statement. But the solution here isn't to do that either. You're potentially running a bunch of queries here, right? One to get the list of categories, then one for each of those categories to see if the post uses it. Wouldn't it be better if you just ran one query for all the categories and it told you whether the post used each one? SELECT bc.catID, bc.catTitle, NOT ISNULL(bpc.postID) AS inuse FROM blog_cats bc LEFT JOIN blog_post_cats bpc ON bc.catID = bpc.catID WHERE bpc.postID = ? ORDER BY bc.catTitle Prepare that query, bind in your $postID, execute it, then fetch all the results from it. Each row will tell you the category ID and name, as well as whether it is in use for the post.
  15. Current standards are to create responsive websites using CSS media queries. Don't detect the user agent, don't detect mobile or desktop. No Javascript. You should be able to open the site on your desktop browser, shrink the window, and see the mobile experience.
  16. No, for assorted reasons including "I don't know what $item is so I don't know how to check what category it is in". If you can at least figure out that part, if ($item->???() != "courses") {
  17. If you need to post more code, please use the Code <> dialog to do it. Much easier to read that way. Seems you would handle the product category in foreach ( $items as $item ) { $product_id = $item->get_product_id(); $product_ids[] = $product_id; } there. Like foreach ( $items as $item ) { if (/* the product category is good to show */) { $product_id = $item->get_product_id(); $product_ids[] = $product_id; } } How you go about deciding whether to show, I can't tell. Do you know what method(s) you need to call on $item?
  18. The change you need to make isn't in there. Where is my_purchased_products handled?
  19. Sounds kinda complicated, doesn't it? Having to store the current balance for each row. And it's only correct at the moment in time when the row was entered. So if you want to make a change you have to go find the most recent transaction to see what the balance was after it finished. Don't do it. For the moment, the balance is the sum of all transactions. As in do a query that gets a SUM(add) of all the transaction. That's your balance.
  20. Too bad there aren't any places on the internet where you can upload files, huh?
  21. According to the README, the constants are called "MARGIN_LEFT" and "MARGIN_RIGHT".
  22. Use your operating system's package manager. If their repositories are not up to date, find a third-party repo that is.
  23. Well for one, var json = JSON.parse(JSON.stringify(data)); don't do that. You're starting with an object, turning it into a JSON string, and then turning it right back into an object. There's no point. That aside, one improvement would be to use object syntax instead of array syntax for accessing members. Array syntax with [ ]s is fine when the name is in a variable, or it has some weird name you know but can't write out (like it has hyphens or symbols), but for names like "students" there's no need. Example: for (var key in data.students) { (note that this is using the original data variable you started with) An easy second thing is semicolons. Control structures, like for loops, don't need semicolons after the body.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.