Android Question Internal Server Error

Stefano Di Chiano

Active Member
Licensed User
Hi,
I'm trying to run a php script after scanning a qr code and I get the following error:
ResponseError. Reason: Internal Server Error, Response:
This is the activity where I do the scan and try to run the script:
Activity scanner:
#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#End Region

Sub Process_Globals
    Dim nativeMe As JavaObject
    Dim rp As RuntimePermissions
End Sub

Sub Globals
    Private accountImage As ImageView
    Private backgroundImage As ImageView
    Private bottomImage As ImageView
    Private btnFlash As Button
    Private btnNotifica As Button
    Private btnNotificaBottom As Button
    Private btnNotificaBottom2 As Button
    Private btnNotificaBottom3 As Button
    Private btnSettings As Button
    Private btnStart As Button
    Private btnStop As Button
    Private lblNotifica As Label
    Private lblNotificaBottom As Label
    Private lblNotificaBottom2 As Label
    Private lblNotificaBottom3 As Label
    Private lblQr As Label
    Private logoImage As ImageView
    Private logopiccoloImage As ImageView
    Private qr1 As QRCodeReaderV102
    Private oldString As String = ""
    Private qrImage As ImageView
    Private lblLat As Label
    Private lblLon As Label
    
    Dim GeoLoc As GeoLocator
'    Dim locuser As Location
'    Dim locqr As Location
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Scanner")
    nativeMe.InitializeContext
    qr1.ScanNow = True
    qr1.Visible = False
    Log(qr1.BackFacingCamera)    'see the popup help when entering this method - check if there is a back facing camera and return the ID of the camera
    Log(qr1.FrontFacingCamera)   'see the popup help when entering this method - check if there is a front facing camera and retutn the ID of the camera
    Log(qr1.CAMERA_BACK)         'see the popup help when entering this method
    Log(qr1.CAMERA_FRONT)           'see the popup help when entering this method
    qr1.CameraId = qr1.CAMERA_BACK
End Sub

Sub Activity_Resume
    If Starter.GPS1.GPSEnabled = False Then
        ToastMessageShow("Please enable the GPS device.", True)
        StartActivity(Home)
    Else
        Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
        wait for Activity_PermissionResult (Permission As String, Result As Boolean)
        If Result Then
            GeoLoc.Initialize("GeoLocation")
        End If
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        StartActivity(Home)
        Activity.Finish
    End If
    Return True
End Sub

Sub qr1_result_found(retval As String, img As Object)
    If oldString <> retval Then
        oldString = retval
        Log("B4A: " & oldString)
        lblQr.Text = oldString
        Dim qr As QRGenerator
        qr.Initialize(qrImage.Width)
        qrImage.Bitmap = qr.Create(oldString)
'        Dim bm As Bitmap = img
'        qrImage.Bitmap = bm
        nativeMe.RunMethod("playTone", Null)
        qr1.stopScan
        qr1.Visible = False
        VerificaQRCode(retval)
    End If
End Sub

Sub btnStop_Click
    qr1.stopScan
    Sleep(0)
    qr1.Visible = False
End Sub

Sub btnStart_Click
    Dim Result As Boolean = True
    If Not(rp.Check(rp.PERMISSION_CAMERA)) Then
        rp.CheckAndRequest(rp.PERMISSION_CAMERA)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    End If
    If Result Then
        qr1.Visible = True
        Sleep(0)
        qr1.startScan
    End If
End Sub

Sub btnSettings_Click
    
End Sub

Sub btnNotificaBottom3_Click
    
End Sub

Sub btnNotificaBottom2_Click
    
End Sub

Sub btnNotificaBottom_Click
    
End Sub

Sub btnNotifica_Click
    
End Sub

Sub btnFlash_Click
    If (qr1.isFlashOn = True) Then
        qr1.setFlashOff
    Else
        qr1.setFlashOn
    End If
End Sub

Sub JobDone (Job As HttpJob)
    ProgressDialogHide
    If Job.Success Then
        Dim parser As JSONParser
        Dim res As String
        Dim action As String
        res = Job.GetString
        Log(Job.GetString)
        parser.Initialize(res)
        Select Job.JobName
            Case "Verificapartner"
                action = parser.NextValue
                If action = "Not exist" Then
                    ToastMessageShow("Partner doesn't exist", True)
                Else If action = "Not a partner" Then
                    ToastMessageShow("User is not a partner", True)
                Else If action = "Not active" Then
                    ToastMessageShow("User is not active", True)
                Else
                    Log(action)
                End If
        End Select
    Else
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub

Sub VerificaQRCode(codice As String)
    Dim Job1 As HttpJob
    Job1.Initialize("Verificapartner", Me)
    Job1.Download2(Main.strURL & "verificapartner.php", Array As String("Email", codice))
    ProgressDialogShow("Connecting to server...")
    'verifica esistenza partner
        'dato il codice, verifico se esiste nel db ed è di tipo PAR o SPO
    'verifica se partner è attivo
        'dato il codice, verifico se attivo=1
    
    'confronta gps locale con gps partner
        'dato il codice, prendo le coordinate, poi calcolo la distanza con la posizione locale
    'verifica scansione settimanale
    'se tutto ok --> effettua transazione
    'altrimenti notifico il problema
End Sub

Sub GeoLocation_Location(success As Boolean, Lattitude As Double, Longitude As Double, info As String, isMockLocation As Boolean)
    Log($"GeoLocation_Location(${success}, ${Lattitude}, ${Longitude}, ${info}, ${isMockLocation})"$)
    If success Then
        GeoLoc.geoAddress
        Log(GeoLoc.Address)
        Log(GeoLoc.City)
        Log(GeoLoc.Country)
        Log(GeoLoc.KnownName)
        Log(GeoLoc.PostalCode)
        Log(GeoLoc.State)
    End If
End Sub

#if Java

import android.media.ToneGenerator;
import android.media.AudioManager;

  public void playTone() {
      final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
      tg.startTone(ToneGenerator.TONE_PROP_BEEP);
  }     

#End If

I'm attaching the php script that I need to run after the scan (the php script I call it's not named "script.txt" of course).
Where do you think I did wrong?
 

Attachments

  • script.txt
    1.2 KB · Views: 208

DonManfred

Expert
Licensed User
Longtime User
Based on the error the problem is in your php-script.
Start debugging the PHP first; call it in a browser. Enable showing errors in the PHP.
 
Upvote 0
Top