HTTP_POST.
#1

If I write more lines with HTTP_POST lines in file are absolutley random.

pawn Код:
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=1. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=2. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=3. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=4. line", "", "");
HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=5. line", "", "");

dest.txt
Код:
5.
2.
3.
4.
1.
...then
Код:
1.
3.
5.
2.
4.
Every time another sequence.


test.php
Код:
<?php
if (isset($_GET["filename"]) && isset($_GET["input"]))
{
    $readfile = fopen("files/".$_GET["filename"], "a");
    chmod("files/".$_GET["filename"], 0777);
    fwrite($readfile, $_GET["input"]."\r\n");
    fclose($readfile);
}
?>
Reply
#2

You're sending the HTTP requests at the exact same time, there is no way of deciding which will reach the server first.
Reply
#3

and why are you using HTTP_POST if you're not sending any post variables?
Reply
#4

Pawn script is sequential. So first is send 1. line, then 2., 3., 4., 5., ...
But you're right. All 5 lines are sent only in 1-3ms.

I tryed to open:
Код:
myweb.cz/test.php?filename=dest.txt&input=1. line
myweb.cz/test.php?filename=dest.txt&input=2. line
myweb.cz/test.php?filename=dest.txt&input=3. line
myweb.cz/test.php?filename=dest.txt&input=4. line
myweb.cz/test.php?filename=dest.txt&input=5. line
myweb.cz/test.php?filename=dest.txt&input=6. line
myweb.cz/test.php?filename=dest.txt&input=7. line
myweb.cz/test.php?filename=dest.txt&input=8. line
myweb.cz/test.php?filename=dest.txt&input=9. line
myweb.cz/test.php?filename=dest.txt&input=10. line
myweb.cz/test.php?filename=dest.txt&input=11. line
myweb.cz/test.php?filename=dest.txt&input=12. line
myweb.cz/test.php?filename=dest.txt&input=13. line
myweb.cz/test.php?filename=dest.txt&input=14. line
myweb.cz/test.php?filename=dest.txt&input=15. line
myweb.cz/test.php?filename=dest.txt&input=16. line
myweb.cz/test.php?filename=dest.txt&input=17. line
myweb.cz/test.php?filename=dest.txt&input=18. line
myweb.cz/test.php?filename=dest.txt&input=19. line
myweb.cz/test.php?filename=dest.txt&input=20. line
At the same time in mozilla.

1st result:
Код:
2. line
1. line
4. line
3. line
5. line
6. line
7. line
8. line
9. line
10. line
11. line
12. line
13. line
14. line
15. line
16. line
17. line
18. line
19. line
20. line
Second result:
Код:
1. line
2. line
3. line
4. line
6. line
5. line
7. line
8. line
10. line
11. line
12. line
9. line
13. line
14. line
15. line
16. line
17. line
18. line
19. line
20. line
So it isn't a SA:MP bug. I have to make small intervals between sending.


EDIT:
Quote:
Originally Posted by i514x_
Посмотреть сообщение
and why are you using HTTP_POST if you're not sending any post variables?
test.php?filename=var1&input=var2
Reply
#5

you're sending variables via GET to PHP not via POST
so you should change HTTP_POST to HTTP_GET

//edit: if you want it via POST do it like that:

pawn Код:
HTTP(playerid, HTTP_POST, "myweb.cz/test.php", "filename=dest.txt&input=1. line", "");
Reply
#6

I am not sure but I think HTTP(playerid, HTTP_POST, "myweb.cz/test.php", "filename=dest.txt&input=1. line", ""); and HTTP(playerid, HTTP_POST, "myweb.cz/test.php?filename=dest.txt&input=1. line", "", ""); is the same.
However my method works.
Reply
#7

No, when you put contents in the query string (protocol://address.domain/path?query string#hash, you only need to do a GET request. POST requests should only be used when you send stuff in the data parameter for HTTP (you access those in PHP with $_POST[ .. ]).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)