Jump to content

Jacques1

Members
  • Posts

    4,207
  • Joined

  • Last visited

  • Days Won

    209

Everything posted by Jacques1

  1. Why do you want to clone the VM for each site?
  2. Before you jump to complex applications, learn the basics. Since almost nobody bothers to learn mysqli properly, I recommend you just drop it and switch to PDO. You must never insert user input directly into SQL query or any other language context. Never. This is extremely dangerous, because it allows anybody on the Internet to obtain sensitive data, manipulate data or even take over the entire server. Do not let that happen. Use prepared statements and start thinking about security. Your query is also broken. You claim to provide data for the ID column, but then you don't. This isn't valid. If you want to use the default value of the column (e. g. an auto-incremented integer), leave it out. Otherwise you must specify a value. Copying all POST parameters into separate variables doesn't make sense either. You already have those values in the $_POST array. Just use them.
  3. The code is very odd, pretty much from top to bottom. Are you using a good IDE with code analysis? It should show several complaints. Your car interface is fine. However, then you define this strange base class with methods coming out of nowhere. I guess you want the Template method pattern, but then you need to define the template methods (typically they're abstract). Starting out with a generic interface and then immediately setting a very specific base implementation in stone is also odd. The whole point of an interface is to not dictate implementation details. The inner workings of a car are irrelevant; it just has to be able to drive, stop, turn etc. You're free to define a base class for your own cars, but then don't call it “Car”. The cars of somebody else may work entirely different. Traits exist to provide features (mostly public methods, rarely attributes) which can be mixed into existing classes. For example, Ruby has the big Enumerable mixin which adds lots of useful methods to collection-like classes. It's very much like inheritance, except that you can have multiple providers. A trait which only has protected method doesn't make much sense. I think you're again confusing the outer API of a class with its inner workings. Traits are about the API.
  4. C'mon, is this your first day on the Internet? Have you never heard of Google? Hint: The ampersand symbol separates the parameters.
  5. Simply throwing two scripts together will likely cause name collisions all over the place. Use one script where you create multiple SourceQuery objects (assuming you want to connect to multiple servers). You can put the connection and processing code into a function, so that it's easy to repeat the actions.
  6. I'm sure there are many things you want. The difficult part is to get them. What I can do is move your thread to the job section. Some programmers are willing to do small jobs like this one.
  7. Have you read the documentation? I can see a “depth” parameter there.
  8. If you read the other replies, you can.
  9. This may sound crazy to you, but have you considered trying it? A more interesting question would be: Is this good programming? I don't think so. Strange arrays with magic numbers coming out of nowhere are usually the last thing you want. A properly named variable or constant, possibly even with inline documentation is far bette than those code-golf-style one liners. Your use of the boolean || operator doesn't make sense either. I guess you want a shorthand for a default value. PHP 7 has the null coalescing operator: $pt_overall = $a_meaningful_array_name[$overall] ?? 0; Otherwise you'll have to use the ternary operator: $pt_overall = isset($a_meaningful_array_name[$overall]) $a_meaningful_array_name[$overall] : 0;
  10. “The only problem” is that you don't understand what the code even does and are now trying to approach the task with trial-and-error. This isn't going to work. Programming is not about luck.
  11. I suggest you forget about PHP for now and just try to understand the basic logic. How does rolling a dice once work? What are the exact steps? Then how does rolling a dice 5,000 times work? What do you have to change? Write this down as pseudo code or in plain English. When you know exactly what you need to do, then you can write the PHP code. Making random code changes and hoping that the script will at some point do what you want isn't a very effective strategy.
  12. And “adventure_details” is what? The name of the script? A virtual filename? Be more specific. Ideally, post a full example URL. I definitely don't recommend simply searching the entire URL for the string, because this completely ignores the structure of URLs and can lead to false positives.
  13. If the editor is very old (pre PHP 5.4), then it might not recognize the short array syntax. Get an update or switch to a proper IDE like Netbeans or Eclipse.
  14. As I already said, use cURL. If there are still problems, turn your error reporting all the way up and post all errors/warnings/notices as well as the full response from the verification service. We're not sitting in front of your screen, so it's your job to provide relevant information. We cannot debug your code based on “It doesn't work”. In any case, copying and pasting random code from the Internet is definitely not a good idea. Most of it is outdated and/or poorly written. Either read the official documentation and write your own code. Or use a well-known library (I'm not sure if there is one for the new reCAPTCHA).
  15. So what exactly “fails”? Be more specific. Officially, Google expects a POST request. You're sending a GET request (which may or may not work). Abusing the file_get_contents() function for HTTP requests is also problematic, because many systems disable this feature for security reasons. A much more robust solution would be to send a POST request with a proper HTTP library like cURL.
  16. Use a stack. Opening parentheses (or their indexes) get pushed onto the stack; whenever you encounter a closing paranthesis, you pop the stack. Is this homework?
  17. For some reason, you keep switching between the right syntax and the wrong syntax. It's INTERVAL 3 DAY Teh manual
  18. This is the JavaScript section. Your thread has already been moved. If your code is copied and pasted from somebody else and you neither understand it nor know enough about JavaScript to write your own code, that's a problem. So what do you know? Where can we start? In any case, I strongly recommend against copypasta. Sure, it yields quick results at first. But then you hit the brick wall and are unable to do anything.
  19. Your request doesn't make much sense to me. You already have multiple forms which do exactly what you claim to not understand. For example, your Frequency Calculator takes two parameters and caculates the result. You can literally copy-and-paste the code, adjust the equation and field names and be done with it. What also confuses me is that you keep talking about PHP, but your calculators are pure JavaScript. PHP is completely irrelevant for the task.
  20. This is not a good idea, because warning and notices can happen even in perfectly written code. For example, it's sometimes valid or even necessary to perform actions that may fail: The password_hash() function checks different randomness sources like /dev/urandom, and that alone can trigger warnings (along the lines of: “Access to path restricted.”). Stopping the script on those warnings will render it unusable. It's even worse if you use libraries or other third-party software, because a lot of programmers use notices and warnings for exactly this purpose: as notices and warnings. They don't assume you're turning everything into fatal errors. Why do you need to stop the entire script? Just log all messages and check them regularly.
  21. I would consider using a vector graphic (i. e. SVG) where you can actually rotate the needle with a parameter. This will be a lot less painful than raster image manipulation.
  22. It's “valid” in the sense that PHP can handle it, but it's nonsense. Either there's a typo, or the author doesn't know what he's doing.
  23. I doubt that you keep the statement open indefinitely. You probably have quick processing cycles after which all data gets destroyed. If you don't have this model, you have bigger problems, because then you need to worry about all data that might pile up, not just the result sets. When in doubt, measure the memory usage. Or free the result set just-in-case, if that makes you feel better.
×
×
  • 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.