Hello,
i've a strange problem which costed me quite a bit of time to debug, still I don't know why my php file won't accept the string of parameters.
Note that the php files are working well, I use them on other projects in combination with another development environment.
So at a certain point I thought it's the database which is the culprit, but no.
I don't want to use JSON for this although I could, it should work also with these few parameters.
I also stopped using jRDC to be in between my app(s) and the DB, and fall back to PHP as I don't want to renew the key each time SSL is renewed (there is probably a script to to that)
and next to that it suddenly stopped working even after renewing the key and restarting the server. I don't need speed or async for this.
Anyway for me personally this is more convenient.
In short, if I use more than 1 parameter, then Poststring seems not working. Well that is that the parameters are not accepted or ignored but it returns succesfully.
I also used a nice website https://ptsv2.com where you can check what your script actually POSTs.(see below)
When I use only this in B4J, URLupdloginstat represents an URL:
in combination with this:
Then each time id=1 is send the disabled column gets incremented just fine
But when I use one of these in B4J, (behind the tested lines you can see the outcome as received on the POST test site):
of which I think this one is correct:
because it results in this string disabled=1¬ification=blablabla&id=1 which normally is accepted.
in combination with this php, which is normally working correct but not with the received data:
Returned is: Something went good,
While actually nothing changed in the db.
Does anyone have an idea why the parameters are not accepted?
Thanks!
i've a strange problem which costed me quite a bit of time to debug, still I don't know why my php file won't accept the string of parameters.
Note that the php files are working well, I use them on other projects in combination with another development environment.
So at a certain point I thought it's the database which is the culprit, but no.
I don't want to use JSON for this although I could, it should work also with these few parameters.
I also stopped using jRDC to be in between my app(s) and the DB, and fall back to PHP as I don't want to renew the key each time SSL is renewed (there is probably a script to to that)
and next to that it suddenly stopped working even after renewing the key and restarting the server. I don't need speed or async for this.
Anyway for me personally this is more convenient.
In short, if I use more than 1 parameter, then Poststring seems not working. Well that is that the parameters are not accepted or ignored but it returns succesfully.
I also used a nice website https://ptsv2.com where you can check what your script actually POSTs.(see below)
When I use only this in B4J, URLupdloginstat represents an URL:
B4X:
j.PostString(URLupdloginstat,"id="&id) 'id=1
in combination with this:
PHP:
<?php
//disable errors when live
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'config.php'; //connection is working OK
try {
$stmt = $pdo->prepare("UPDATE IGNORE pagecontrol SET disabled=disabled+1 WHERE id=:id");
$stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
$affected_rows = $stmt->rowCount();
if($stmt->execute()) { echo "Something went good"; } else { echo "Something went wrong"; };
}
catch(PDOException $e)
{
echo "Something went wrong" . $e->getMessage();
}
var_dump($_POST);
$pdo = NULL;
?>
But when I use one of these in B4J, (behind the tested lines you can see the outcome as received on the POST test site):
B4X:
Sub Updateloginctrl(id As Int,ds As Int,notiftxt As String)
Log ("id is " & id & "DS is " & ds & "text is " & notiftxt)
Dim j As HttpJob
j.Initialize("j", Me)
'j.PostString(URLupdloginstat,Array("disabled="&ds,"notification="¬iftxt,"id="&id)) 'results in--> [Ljava.lang.Object;@464b4d18
'j.PostString(URLupdloginstat,"disabled=&ds notification=¬iftxt id=&id") 'results in--> disabled=&ds notification=¬iftxt id=&id
'j.PostString(URLupdloginstat,"disabled=ds¬ification=notiftxt&id=id") 'results in--> disabled=ds¬ification=notiftxt&id=id
'j.PostString(URLupdloginstat,"disabled="&ds&"notification="¬iftxt&"id="&id) 'results in--> disabled=0notification=blablablaid=1
'this should be the correct one for sending, this is the same string as used in another dev ide
j.PostString(URLupdloginstat,"disabled="&ds&"¬ification="¬iftxt&"&id="&id) 'results in--> disabled=1¬ification=blablabla&id=1
'j.GetRequest.SetContentType("application/x-www-form-urlencoded") 'makes no difference if used
'j.PostMultipart(URLupdloginstat, CreateMap("disabled": ds, "notification":notiftxt,"id":id), Null) 'java error in B4J
...........
of which I think this one is correct:
B4X:
j.PostString(URLupdloginstat,"disabled="&ds&"¬ification="¬iftxt&"&id="&id)
in combination with this php, which is normally working correct but not with the received data:
PHP:
<?php
//disable errors displaying when live
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'config.php'; //connection is working OK
try {
$stmt = $pdo->prepare("UPDATE IGNORE pagecontrol SET disabled = :disabled, notification = :notification WHERE id= :id");
$stmt->bindParam(':disabled', $_POST['disabled'], PDO::PARAM_INT);
$stmt->bindParam(':notification', $_POST['notification'], PDO::PARAM_STR);
$stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
if($stmt->execute()) { echo "Something went good"; } else { echo "Something went wrong"; };
}
catch(PDOException $e)
{
echo "Something went wrong" . $e->getMessage();
}
var_dump($_POST);
$pdo = NULL;
?>
While actually nothing changed in the db.
Does anyone have an idea why the parameters are not accepted?
Thanks!