Sub Button1_Click
jop1.Initialize("at",Me)
jop1.PostString("http://www.mysite.com/insert.php","$num="&EditText1.Text)
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
If Job.JobName ="at" Then
ToastMessageShow("yes",True)
Else
ToastMessageShow("no",True)
End If
End If
Sub Button1_Click
jop1.Initialize("at",Me)
jop1.PostString("http://www.mysite.com/insert.php","$num="&EditText1.Text)
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
If Job.JobName ="at" Then
ToastMessageShow("yes",True)
Else
ToastMessageShow("no",True)
End If
End If
The problem was finally resolved
The reason for the different codes
PHP
Modern version 5 and above
The corrected code has been placed below for the benefit
B4X:
<?php
include ("conn.php");
$num = strip_tags($_POST["k"]);
$sql="INSERT INTO kkkk(k) VALUES('$num')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
B4X:
<?php
$servername = "";
$username = "";
$password = "";
$dbnamee = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbnamee);
// $conn = mysql_connect($servername, $username, $password) or die (mysql_error());
//@mysql_select_db($dbnamee) or die (mysql_error());
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
B4X:
Sub Button1_Click
jop1.Initialize("at",Me)
jop1.PostString("http://www.mysite.com/insert.php","&k="&EditText1.Text)
End Sub
Sub JobDone(Job As HttpJob)
If Job.Success Then
If Job.JobName ="at" Then
Log("yessssssssssssssss")
Else
Log("noooooooooooooooo")
End If
End If
Thanks Earl
I would also like to complete the implementation of what I started with
You have successfully entered data
Data Display Process:
You have applied this code:
B4X:
Sub JobDone(Job As HttpJob)
If Job.Success Then
If Job.JobName ="show" Then
Dim istream As InputStream
istream=Job.GetInputStream
parser.Initialize
parser.Parse(istream,"parser_import")
istream.Close
' Log("yessssssssssssssss")
' Else
' Log("noooooooooooooooo")
End If
End If
End Sub
B4X:
Sub parser_import_EndElement (Uri As String, Name As String, Text As StringBuilder)
If parser.Parents.IndexOf("item")>-1 Then
If Name="num" Then
num1=Text.ToString
End If
End If
If Name="item" Then
ListView1.AddSingleLine(num1)
End If
End Sub
B4X:
Sub Button2_Click
jop11.Initialize("show",Me)
jop11.Download("http://www.mysite.com/dbphp/select.php")
End Sub
php
B4X:
<?php
include ("config.php");
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<rss version="2.0">
<channel>
<?php>
$sql = "select k from asd";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
?>
<item>
<num><<?php echo $row ['k']; ?><num>
</item>
<<?php } ?>
<item2>
<end> <<?php echo "end"; ?></end>
</item2>
</channel>
</rss>
I have run PHP code on my browser and it works fine
And when you connect it to Basic 4 Android
This error appears:
B4X:
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 1: syntax error
1. You are still using JobDone although it is not needed.
2. You haven't posted the full error message.
3. You can use Xml2Map to parse the XML string.
4. Based on the error message the XML is invalid.
5. Add Log(Job.GetString) and see what you are receiving.
6. I'm not sure why you are using this PHP at all. Better use jRDC2.
1. You are still using JobDone although it is not needed.
2. You haven't posted the full error message.
3. You can use Xml2Map to parse the XML string.
4. Based on the error message the XML is invalid.
5. Add Log(Job.GetString) and see what you are receiving.
.
The last note
I hope to work on jRDC2, but it needs a local server machine to be the intermediary between the application and the remote server on the Internet
I use PHP for this reason only because the broker, PHP does not need a local server, it is on the web server
Can you have jRDC2 running on internet server only ???