Android Question I tried connecting to mySQL database with b4a and it gets an error

alfaiz678

Active Member
Licensed User
share here your full project, all your files: B4A, php and MySQL, it will be easer to help.
This is the project as per your request
Here's a question is it possible to upload the config.php file
Only on hosting
The rest of the commands such as add modification and deletion and .....
Via the app directly
 

Attachments

DonManfred

Expert
Licensed User
This is the project as per your request
there are multiple problems in your php script (i only checked insert.php)

1. Which php version are you running??? I ask because mysql_query is deprecated since years.
2. jop1.PostString do exactly this. the payload is posted to the phpscript. The input can be get via
PHP:
<?php $postdata = file_get_contents("php://input"); ?>
$postdata contains the payload. Note that you need to manually extract the values from the payload as the code above does not parse anything.

Better is to use job.PostMultipart
3. The B4A code misses a DIM for each job you are sending. This is a mistake.
B4X:
Sub Button1_Click
    Dim j As HttpJob
    j.Initialize("at",Me)
    j.PostMultipart("http://www.mysite.com/insert.php",CreateMap("k": EditText1.Text.Trim),Null)
End Sub
in this case php is doing the parsing for you and deliver the value of k in $_POST["k"]

4. Set errorreporting in php so that you see any error in the output if there is an error.
Place this line at the 1. line of the php-scripts
PHP:
error_reporting(E_ALL & ~E_NOTICE);
 
Last edited:

alfaiz678

Active Member
Licensed User
The problem is that I only speak a little PHP
So you can correct the code thanks


Here's a question is it possible to upload the config.php file
Only on hosting
The rest of the commands such as add modification and deletion and .....
Via the app directly
You could answer that question ؟؟
 

DonManfred

Expert
Licensed User
Last edited:

DonManfred

Expert
Licensed User
If you are not familar with php then i suggest to
1. Switch to jRDC2 (you need a VPS). Best and safest Solution
2. Learn PHP or hire someone who write the php-code for you
3. Use jdbcsql. This only works if your Database is accessible from outside. Not recommended for production apps!
 

alfaiz678

Active Member
Licensed User
thanks for the information
Even though the insert was successful with me (insert)
The problem with me was in the view (select)
And you did
Tweaking the part that works

I will try again
 
Top