Hi Guys
Working through the excellent tutorial from Erel and some over memebrs using MYSQL to insert/List data in a MySql Database/Table.
List view work fine, but as soon as I try to Insert a New record it tells me
Response from server: Access denied for user 'root'@'localhost' (using password: NO)
Access denied for user 'root'@'localhost' (using password: NO)
I've got 2 PHP file, get.php for getting the info, and ins.php for inserting.
The Username/Paths/Password/Database all is entered correctly. Double/Tripple check that
Can anyone see something wrong in the code. I did give permissions in Phpmyadmin, for domain to access my Database.
PHP Insert code
I have tried Poststring and Download 2 in Httputils. Same results
Thanks
Danie
Working through the excellent tutorial from Erel and some over memebrs using MYSQL to insert/List data in a MySql Database/Table.
List view work fine, but as soon as I try to Insert a New record it tells me
Response from server: Access denied for user 'root'@'localhost' (using password: NO)
Access denied for user 'root'@'localhost' (using password: NO)
I've got 2 PHP file, get.php for getting the info, and ins.php for inserting.
The Username/Paths/Password/Database all is entered correctly. Double/Tripple check that
Can anyone see something wrong in the code. I did give permissions in Phpmyadmin, for domain to access my Database.
B4X:
'Activity module
Sub Process_Globals
Private LIST_CATCH As String
End Sub
Sub Globals
Type TwoLines (First As String, Second As String)
Dim ViewCatchersList As ListView
Private ExitBtn As Button
Private NameSurnametxt As EditText
Private AddressTxt As EditText
Private AddBtn As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
FetchNamesList
End Sub
Sub FetchNamesList
ProgressDialogShow("Fetching list of Name")
ExecuteRemoteQuery("SELECT NameSurname, Address FROM catchers ", LIST_CATCH)
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.xxxx.co.za/get.php", Query)
End Sub
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case LIST_CATCH
Dim GetCatchList As List
GetCatchList = parser.NextArray 'returns a list with maps
For i = 0 To GetCatchList.Size - 1
Dim m As Map
m = GetCatchList.Get(i)
'We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item.
Dim tl As TwoLines
tl.First = m.Get("Address")
tl.Second = m.Get("NameSurname")
ViewCatchersList.AddTwoLines2(tl.First, tl.Second, tl)
Next
Case "INSERT_CATCH"
'print the result to the logs
Log(Job.GetString)
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub ExitBtn_Click
Activity.Finish
End Sub
Sub AddBtn_Click
Dim InsCatchers As HttpJob
InsCatchers.Initialize("INSERT_CATCH", Me)
InsCatchers.Download2("http://www.xxx.co.za/ins.php", Array As String("NameSurname", NameSurnametxt.text, "Address", AddressTxt.text))
End Sub
PHP Insert code
B4X:
<?
$databasehost = "localhost";
$databasename = "db";
$databaseusername ="user";
$databasepassword = "pw";
$con = mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES 'utf8'");
$Address = $_GET["Address"];
$NameSurname = $_GET["NameSurname"];
$res = mysql_query("Insert into catchers (NameSurname, Address) VALUES ('$NameSurname', $Address)");
print ("I have inserted $NameSurname and $Address in my table");
?>
I have tried Poststring and Download 2 in Httputils. Same results
Thanks
Danie