0
        RequestQueue setRequestQueue = Volley.newRequestQueue(context);
        StringRequest request = new StringRequest(Request.Method.POST, "https://hadibe.com/php/brochure_set_click.php", response -> {

        }, error -> {

        }) {
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> map = new HashMap<>();
                map.put("name", name);
                map.put("country", country);
                map.put("package", context.getPackageName());
                return map;
            }
        };
        setRequestQueue.add(request);

brochure_set_click.php

<?php
require "connect.php";

$name = $_POST["name"];
$country = $_POST["country"];
$package = $_POST["package"];

$insert = "INSERT INTO `$country` (`id`, `name`, `date`, `package`) VALUES (NULL, '$name', CURRENT_TIMESTAMP, '$package')";
mysqli_query($connect, $insert);
?>

Only 25 requests run at the same time. After 1 minute, 25 requests run again. However, it does not respond to requests before this time period has passed.

Trk
  • 95
  • 1
  • 12
  • 1
    **Warning:** Your code is vulnerable to SQL Injection attacks. You should use parameterised queries and prepared statements to help prevent attackers from compromising your database by using malicious input values. http://bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / mysqli. **Never** insert unsanitised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data. – ADyson Sep 16 '22 at 16:25
  • 1
    https://phpdelusions.net/mysqli also contains good examples of writing safe SQL using mysqli. See also the [mysqli documentation](https://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php) and this: [How can I prevent SQL injection in PHP?](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) . Parameterising your queries will also greatly reduce the risk of accidental syntax errors as a result of un-escaped or incorrectly quoted input values. If you learnt your current technique from a tutorial or book, please don't use it again. – ADyson Sep 16 '22 at 16:25
  • Well. Why is it only responding to 25 requests? – Trk Sep 16 '22 at 16:28
  • What happens on the 26th? An error? Timeout? Something else? Give us a clue about the actual problem. Maybe your server just ran out of capacity. – ADyson Sep 16 '22 at 16:32
  • Message : com.android.volley.TimeoutError – Trk Sep 16 '22 at 16:34
  • Ok. So probably the server does not have the resources to handle more than 25 concurrent requests. Maybe there's even a limit set somewhere in the webserver settings or something. – ADyson Sep 16 '22 at 16:35
  • 3
    Also your data structure appears to have a design flaw - it looks like you have multiple tables, one for each country, but all of them have the same columns in them. That is denormalised, there is no need for it and it will make it much harder to query the data later, and/or give you problems if you need to add and remove countries, or change the name. Just have one table for all this data, and add an extra column called "country" in which you store the country information. And then go and take a course about relational database design before you mess up anything else :-) – ADyson Sep 16 '22 at 16:38
  • You're right. I am not a professional in this field. I am interested in hobby purposes. I couldn't find a solution for these 25 requests. GoDaddy will drive me crazy :) – Trk Sep 16 '22 at 16:42
  • Ah you're on a cheap shared host...yes they will impose these kinds of usage restrictions to protect their servers and to try and be fair to other customers who are using the same server. Is there some reason you can't send all the data in a single request? – ADyson Sep 16 '22 at 16:43
  • but if data comes from 50 different users at the same time? – Trk Sep 16 '22 at 16:46
  • 1
    oh ok. It sounded like you were queueing those requests all from one user in your android app. If you're operating at a bigger scale like that then you may need your own server not just a cheap shared one. Or consider some sort of scalable cloud hosting. And get a grip on your development practices so you don't leave basic security holes in your code, if you're dealing with that many simultaneous users then presumably you have a lot more users overall? If so, people will take notice of your site and eventually someone will try to attack it. – ADyson Sep 16 '22 at 17:03
  • java.io.IOException: Unexpected end of stream on com.android.okhttp.Address Unfortunately, such an error is also coming. – Trk Sep 18 '22 at 10:27

0 Answers0