Jump to content

Jacques1

Members
  • Posts

    4,207
  • Joined

  • Last visited

  • Days Won

    209

Everything posted by Jacques1

  1. If you compile PHP from source, you can have as many different versions as you want. If you use some package manager, it may be more challenging, but I'm sure Google knows the answer to that as well.
  2. The code doesn't make any sense. So you want to validate the input. But instead of validing the input, you randomly HTML-escape it, then SQL-escape it and finally run the completely garbled data through a regex check. Of course this will fail. Even the regex doesn't make sense to me. Why can I have all kinds of useless special characters, but a simple umlaut isn't allowed? I think most of the code should be rewritten: Come up with a sensible naming policy. Either go with strict rules (e. g. only alphanumerical characters, underscores and hyphens), or be liberal (e. g. all printable Unicode characters). You know that there's more than ASCII, right? Stop calling random functions. HTML-escaping is strictly for HTML contexts; you use it right before you output data. SQL-escaping is strictly for SQL contexts and actually obsolete; nowadays, we indeed use prepared statements. And what's up with the stripslashes()? The last time that function made sense was somewhere in the late 90s when “Magic Quotes” still existed. Always validate the raw, unaltered input. What's the point of validation when you make it fail? Avoid writing PHPHTML spaghetti code. Right now, I can barely see the application logic, because there are HTML fragments all over the place.
  3. Why would you do that? You've just scraped the ISBNs from some text file (while completely ignoring our warnings), now you again store the numbers in a text file? What are you going to do with the ISBNs?
  4. Have you read any of the replies? The error message tells you exactly what you need to do. taquitosensei even posted the code. And Barand additionally told you the timezone you're in. What more do you need? A tutorial for using the keyboard?
  5. Yes, because it's much simpler. By the way, I can guarantee you that the OP has not created an extra table and just keeps using the old magic numbers together with Psycho's code. And the problem is what, exactly?
  6. With a proper data format, this would be a 30-seconds job and not take 6 hours (and counting). So maybe you should care about your decisions. If you're interested in learning PHP, I'm sure we can figure out a more reasonable approach after you've described the actual problem (where does the data come from etc.).
  7. Dude. Stop posting your entire application in every single reply to every single person. We can all see it.
  8. Where does this weird input string come from? Why not use a proper data format like JSON?
  9. Nonsense, this doesn't cover the last two cases. Let's try it again: '~\\A(?:[\\d/]+[a-z]{0,4}|[a-z]{1,4})[\\d/]*\\z~i'
  10. I haven't read the entire code, but I'm fairly sure you can make it a lot simpler and more robust if you use the official phpDocumentor parser instead of implementing your own (by the way, it's parse, not “phase”).
  11. The question is far, far too vague. Nobody is going to write a 50-pages “How to implement a publishing system” tutorial. Break your project into concrete tasks and then ask specific questions, ideally with actual code.
  12. I would actually avoid those magic status numbers altogether, because they make no sense on their own and require you to constantly explain and convert them. Use an ENUM type where you can actually store strings like “waiting” and “delivered”.
  13. Sure, but we're not stupid. When I see the same thread popping up in n different forums, my motivation for investing time into a reply drops to zero.
  14. So you're allowing up to 4 alphabetical characters in one block? Or can I have something like “1A2B”? For the former: '~\\A[\\d/]+[a-z]{0,4}[\\d/]+\\z~i' Read: an arbitrarily long sequence of digits and forward slashes followed by up to 4 alphabetical characters followed by another arbitrarily long sequence of digits and forward slashes.
  15. Are you having your period, or what? I have no idea what you're reading into my post, but I'm simply pointing out two problems: There's no guarantee that the MySQL data type of the ID column fits into a PHP integer. For example, a 32-bit PHP integer cannot even hold a MySQL INT UNSIGNED, let alone a BIGINT. And a MySQL BIGINT UNSIGNED doesn't fit into a PHP integer on any platform. When the input isn't an integer due to an error, casting silently changes this data and keeps the application going. This is no big deal for queries without side effects. But if I'm trying to change a record and get the ID wrong, I definitely do not want the application to “guess” which record I meant.
  16. mysqli::set_charset() Also make sure that your HTML documents are declared as UTF-8 (with a Content-Type: text/html;charset=UTF-8 HTTP header and a <meta charset="UTF-8"> element).
  17. You can't override a method and then change the signature entirely. This wouldn't make any sense, because one of the core principles of OOP is that you can substitute superclasses with subclasses. You're trying to violate this principle, because $obj->display() would work for instances of Base but not for instances of Editor. What you can do of course is make the parameter optional in both classes and throw an InvalidArgumentException when null is passed to the method of Editor. Or try to set up a less confusing architecture (e. g. two different methods).
  18. Casting IDs into PHP integers is not a good idea, because it can change the user input (which is potentially dangerous) and will fail when the IDs exceed the upper limit of the PHP integer type. There is no easy solution, mainly because the mysqli API is poorly designed. So before you introduce bugs or poke holes into the application security, I'd go with the long version.
  19. You're horribly confused. You don't seem to understand what a row and what a column is and how tables are structured. What you've done is create an empty(!) table with four columns (not rows!): fija, fijo, f and a. So the table looks like this: fija | fijo | f | a ------+------+---+--- (no rows) I really don't know what to tell you at this point other than: Put the script away and learn the basics.
  20. Literally duplicating the web application for every new user is a very bad idea. Not only does this waste a lot of space; you'll also get into deep trouble when you have to update the code, because now you have to update every single instance – and if one of the instances has departed from the original code, you're in merge hell. PHP can render web content dynamically, and that's exactly what you want to do in this case: You have a single application with multiple users; every user has their own personal data, so the application can display individual web pages. In any case, I strongly recommend you learn PHP before trying to implement a complex project like this. You need to actually know what you're doing if you want this to be a success (no, there's no step-by-step tutorial).
  21. So what's the content of $users? var_dump($users); Are you selecting from the right table? Does the table even have rows? Do they have an id column?
  22. You cannot iterate over $users as $users. You need to concentrate and carefully read the code. Then read it again. And maybe a third time. If you make a new mistake on every line you write and then cannot fix it yourself, programming will be very difficult.
  23. How are you going to deal with daylight saying time? The duration between 21:00 and 07:00 is not always 10 hours. It can also be 9 or 11 hours depending on the time zone and date. So if you're dealing with concrete dates, it would make a lot more sense to pass actual timestamps to the function. The user may still just enter “21:00” and “07:00”, but your application would transform that into proper absolute timestamps.
×
×
  • 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.