Hi all,
I've been using mysql with b4a for a long time and I've never had problems like this.
From my app I point to a connectdbxandroid posed on mywebsite1 and I get the error: Empty query
If I move the connectdbxandroid to the mywebsite2 web area and change my app to point to that, everything works.
Same DB, same App.
PHP version is 5.6 (both)
I add code.
CONNECTDBXANDROID
QUERY
JOBDONE
ERROR
I don't understand why it appens
Thanks for support
Marcom
I've been using mysql with b4a for a long time and I've never had problems like this.
From my app I point to a connectdbxandroid posed on mywebsite1 and I get the error: Empty query
If I move the connectdbxandroid to the mywebsite2 web area and change my app to point to that, everything works.
Same DB, same App.
PHP version is 5.6 (both)
I add code.
CONNECTDBXANDROID
B4X:
<?php
session_start();// come sempre prima cosa, aprire la sessione
$client = "xxxxxx";
$nome = "xxxxxx";
$password4 = "xxxxxx";
$directory = "xxxxxx";
$tabellad = "xxxxxx";
date_default_timezone_set('Europe/Rome');
$connessione=mysqli_connect($client,$nome,$password4,$directory);
if (!$connessione) {
echo('Errore di connessione: ' . mysqli_error());
}
mysqli_set_charset ($connessione , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($connessione, $query);
if (mysqli_errno($connessione)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($connessione);
}
else
{
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
$res = json_encode($rows);
echo $res;
mysqli_free_result($sth);
}
mysqli_close($connessione);
?>
QUERY
B4X:
' Send a POST request
Dim jobx As HttpJob
Main.Qry="Select * FROM pr11azienda"
Msgbox2("QRY: " & Main.Qry,"BBBooking","OK","","",LoadBitmap(File.DirAssets,Main.MsgLogo))
jobx.Initialize("Job0", Me)
jobx.PostString(Main.ServerUrl, Main.Qry)
JOBDONE
B4X:
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job0"
Dim parser As JSONParser
Dim response As String
response = Job.GetString
Log(response)
parser.Initialize(response)
rows = parser.NextArray
If rows.size > 0 Then
' Msgbox("Risultato 0: " &rows,"")
Dim m As Map
' Msgbox("rows.size " & rows.size,"")
m = rows.Get(0)
Main.pr11nome = m.Get("pr11nome")
Main.pr11indirizzo = m.Get("pr11indirizzo")
messaggio = "pr11nome=" & Main.pr11nome
Msgbox2(messaggio,"BBBooking","OK","","",LoadBitmap(File.DirAssets,Main.MsgLogo))
Log("Messaggio: " & messaggio)
Else
Main.Accesso="no"
messaggio="Utente errato: Accesso non autorizzato"
Msgbox2("Messaggio: " & messaggio,"BBBooking","OK","","",LoadBitmap(File.DirAssets,Main.MsgLogo))
End If
Case "Job1a"
............
............
............
ERROR
B4X:
** Activity (bbnomistanze) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
JobName = Job0, Success = true
array(0) {
}
<br />
<b>Warning</b>: mysqli_query(): Empty query in <b>/web/htdocs/www.preludiocapri.info/home/preludio/prconnectdbxandroid.php</b> on line <b>26</b><br />
<br />
<b>Warning</b>: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in <b>/web/htdocs/www.preludiocapri.info/home/preludio/prconnectdbxandroid.php</b> on line <b>36</b><br />
[]<br />
<b>Warning</b>: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in <b>/web/htdocs/www.preludiocapri.info/home/preludio/prconnectdbxandroid.php</b> on line <b>41</b><br />
bbnomistanze_jobdone (java line: 797)
java.lang.RuntimeException: JSON Array expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextArray(JSONParser.java:62)
at com.mamavi.bbbooking.bbnomistanze._jobdone(bbnomistanze.java:797)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1179)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
java.lang.RuntimeException: JSON Array expected.
** Activity (bbnomistanze) Pause, UserClosed = false **
I don't understand why it appens
Thanks for support
Marcom