dataRows = parser.NextArray Error

teneika

New Member
Licensed User
Longtime User
Hello, I a trying to have my program read fro easyphp and verify the usernames and passwords but i keep receiving this error:

Program paused on line: 139
dataRows = parser.NextArray


This is my code for the program:

Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest

'10.0.2.2 is the IP address that allows the emulator to connect to the local host machine
'runing the WAMP server.

If TaskId = 0 Then

req.InitializePost2("http://10.0.2.2" & "/ncesclogin.php", Query.GetBytes("UTF8"))
hc.Execute(req, TaskId)

End If


End Sub

Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
ProgressDialogHide
End Sub

Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim res As String
res = Response.GetString("UTF8")
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)

Select TaskId
Case login_task_no

Dim valid_login As String = False

Dim dataRows As List
dataRows = parser.NextArray
For i = 0 To dataRows.Size - 1

'Get a data row representing a single gas station.
Dim dataRow As Map
dataRow = dataRows.Get(i)

'Create a string to write to the file.
Dim username As String
Dim password As String

dataRow = dataRows.Get("username")
dataRow = dataRows.Get("password")

If loginedt.Text = username AND passedt.Text = password Then

valid_login = True

End If

Next

End Select


Response.Release

ProgressDialogHide

If valid_login Then

Activity.LoadLayout("main")


Else
Msgbox("Invalid login", "Error")
loginedt.Text = ""
passedt.Text = ""

End If


End Sub


The following is my php file:

<?php

$databasehost = "localhost";
$databasename = "logindatabase";
$databaseusername ="logindatabase";
$databasepassword = file_get_contents("php://input"); #Note: database password = "logindatabase"

$con = mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error());
mysql_select_db($databasename) or die(mysql_error());
$query = "select username, password from user";
$sth = mysql_query($query);

if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>
 

stevel05

Expert
Licensed User
Longtime User
If you run it past that line (click on the play button in the Debug panel) it'll give you an error message.
 
Last edited:
Upvote 0
Top