Jump to content

Jacques1

Members
  • Posts

    4,207
  • Joined

  • Last visited

  • Days Won

    209

Everything posted by Jacques1

  1. Next to the JavaScript console, there's a network tab which shows the exact content of both the request and the response. Use it to debug problems like this.
  2. Jacques1

    cron jobs

    Sure, but that doesn't mean you should put code into some text file and evaluate it. Fetching data from a URL is a clearly defined task, so your script only needs to know the parameters (the URL, maybe additional headers etc.). For example, you could implement a queue in your database, i. e. a table with one row per task. Whenever the cron script runs, it fetches the parameters of the next task, makes the HTTP request and then marks the task as completed (if the request was successful). However, this means you have to manually add the tasks, which may not be practical. Alternatively, you could simply create a list of URLs and iterate over that list over and over again.
  3. What exactly is the problem, anyway? How do you know that only one user is allowed? Are you getting an error message? Are new users somehow blocked? Do old users get thrown out?
  4. And why aren't you using PHP for that?
  5. JSON. Now we still need XML to complete the zoo. C'mon, this is a data format, not a telephone number.
  6. Looks like serialized data.
  7. Never used this, so you're on your own.
  8. PHP 7 has plenty of useful new features, is faster and more efficient. So,yes, it has obvious benefits. But once you've written your code for PHP 7, there's almost no turning back. If the application has to run on all kinds of servers which aren't under your control, that's a problem. http://php.net/manual/en/migration70.incompatible.php
  9. If you're talking about the mysql_* functions, they're hopelessly outdated and have been removed from PHP 7 (they still exist as deprecated functions in PHP 5). No current code should use them. One objective problem is that the old extension doesn't support prepared statements, making it impossible to securely pass values to queries. The two modern alternatives are mysqli and PDO. mysqli is very similar to the old MySQL extension and even has a procedural interface. However, it's rather cumbersome and naturally limited to the MySQL database system. PDO is purely object-oriented, but it's well-designed and supports all current mainstream database systems, not just MySQL. I generally recommend PDO. There are several good tutorials out there.
  10. Which debugger are you using? XDebug? With remote debugging, you can make the IDE listen for debug connections which are triggered by HTTP requests.
  11. Consider using a professional image library like ImageMagick.
  12. You're trying to copy a stream context to the standard input. What is this supposed to do? I tend to use Burp Suite for manual testing. It allows you to intercept actual requests, edit them, repeat them, create new requests etc. For automated tests, cURL actually is the right tool. Trying to create a “fake” request doesn't really make sense to me. You have to go through plenty of parameters, and then you may still miss something, which means your test won't do what an actual request does.
  13. Jacques1

    cron jobs

    Don't do that. Seriously, don't. Fumbling with text files is already a bad idea (we have SQL databases for that). But putting actual PHP code into that file and blindly executing it is so misguided and insecure that I wonder how you even got this idea. Tell us what you want to achieve, not how you think you will achieve it. What do those statements do? I'm fairly sure they are predefined actions, in which case you can use queues in a database.
  14. So? What's the problem? If you're not getting the rows you've expected, there's something wrong with your access column. What's odd is that you're using numeric strings instead of actual numbers. Why? In any case, double-check that the access column in your table indeed has the exact values '0', '1' or '2'. If the column type is (VAR)CHAR or TEXT, there may be spaces or unprintable characters hidden in the strings. The best solution is to switch to a actual integers.
  15. We don't hand out code. If you look at the manual, you'll see that there's a third parameter for a context which can be used to supply additional data. And the HTTP context has a header option for custom HTTP headers.
  16. No need to assemble the URL query manually: '<a href="?'.http_build_query(['type' => $type_id, 'name' => $get_type_3_name_slug, 'page' => $page_number]).'">'
  17. I don't know how Ajax is going to help with this, but JavaScript can create timers. After the page has been loaded, you start with $timeLeft, count down the seconds and display the remaining time somewhere on the page. There are thousands of examples and working implementations, just google for it.
  18. The values you're dealing with (bedspace, antimicrobials, ...) should have numeric IDs, and you should use those IDs rather than some text when the value is selected and stored. When this is done, you can select both the ID and the descriptive text from the table, iterate over the rows and build the dropdown dynamically. <?php const APP_HTML_ENCODING = 'UTF-8'; <?php function html_escape($raw_input, $encoding = APP_HTML_ENCODING) { return htmlspecialchars($raw_input, ENT_QUOTES | ENT_SUBSTITUTE, $encoding); } <?php /* ... */ $antimicrobials = $PDO->query('SELECT antimicrobial_id, description FROM antimicrobials')->fetchAll(); /* ... */ ?> <!-- ... --> <select <!-- ... -->> <?php foreach ($antimicrobials as $antimicrobial): ?> <option value="<?= html_escape($antimicrobial['antimicrobial_id']) ?>"><?= html_escape($antimicrobial['description']) ?></option> <?php endforeach; ?> </select> Feel free to add the logic for preselecting a value.
  19. Laravel is a very popular PHP framework, so there's nothing wrong with it. The flipside is that it's much more abstract than a classical PHP application consisting of a few scripts. There is no contact-us.php file. Depending on what exactly you want to do, you'll have to look at different layers of the application. In short: The URL is resolved by the router which then passes the request to a controller class for processing. When this is done, the actual page content is rendered using views (HTML templates). See the Application Structure for an overview of the directories. So what do you want to do? Change a few bits of HTML? Implement a new feature?
  20. What is Configure? And why does it need extra parameters when it's always the same class? Right now, it seems a much reasonable approach would be to pass $this (which is appearently the Slim application) and possibly other data sources like $request and $response to the class and let it decide which data is needed. If you need extra data for a specific method, use method parameters.
  21. This is far, far too vague to give any kind of advice. We're not psychic. Which CMS are you talking about? And what does “limit users to only certain tables” even mean? Access to data is generally handled within the application, not on a per-table basis. If you post concrete code/tables and concrete questions, I'm sure somebody will be able to help you. But right now, it's really just gibberish.
  22. The reason why I have a problem with abstract example code is that it's very hard to make an informed decision, and sometimes the examples are so bad that the whole discussion is useless for the actual problem. I'm not saying that you should dump your entire application in the forum, but a short description of the underlying project and an extract of the actual code are almost always better than some hypothetical class Foo calling a hypothetical method bar.
  23. The page is no longer accessible (403). In any case, post the output here and write a coherent problem description. Visiting some ever-changing, error-ridden, short-lived site in the hopes of figuring out what your problem is just sucks. And in a few years, the URL is probably dead, and the thread becomes useless.
  24. Don't overwrite the data, just add new data per date. Keeping a few MB of extra information doesn't cost you anything and can later turn out to be useful. Many sites show the weather of previous dates and provide statistics. So a small correction: The records are identified by the ZIP code, the date and the time interval. Split this into separate tables and use numeric IDs.
  25. Possibly with the Template Method pattern. <?php abstract class P { public function foo() { echo 'P before<br>'; $this->inner(); echo 'P after<br>'; } abstract function inner(); } class C1 extends P { public function inner() { echo 'C1 inner<br>'; } } $c1 = new C1(); $c1->foo(); However, since you only post fantasy code, it's hard to tell.
×
×
  • 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.