Dear Experts,
I am trying to insert data to mysql.
I have taken following steps
- Created cng_insert.php on this location
codes in this files are like this
<?php
$servername = "localhost";
$username = "id30649282_hassanz";
$password = "Ahmad7123456";
$database = "id30649282_asiacng";
$dbc = mysqli_connect($servername, $username, $password, $database);
if(!$dbc) {
die("DATABASE CONNECTION FAILED:" .mysqli_error($dbc));
exit();
}
$p_ltr = mysqli_real_escape_string($dbc, $_GET['p_ltr']);
$p_rat = mysqli_real_escape_string($dbc, $_GET['p_rat']);
$p_amt = mysqli_real_escape_string($dbc, $_GET['p_amt']);
$query = "INSERT INTO sales(p_ltr,p_rat,p_amt)
VALUES ('$p_ltr','$p_rat','$p_amt')";
if(mysqli_query($dbc, $query)){
echo "Records added successfully";
}
else{
echo "ERROR: Could not able to execute". $query." ". mysqli_error($dbc);
}
mysqli_close($dbc);
?>
- I tested this php as follows
It mean codes are working but not getting values to insert
- I used following block
globalTempUrl=https://lettered-manners.000webhostapp.com/cng_insert.php?p_lit=
but I click click submit button then following error occurs
Webpage not available
Please help me what I am doing wrong.
Regards
TIMAI2
2
Well, your answer is in your error message:
Understand why from what data / type you are sending, and what the mysql server is expecting for that column in the table.
Also
should these ?
be &
?
Also
see HERE
Sir I have replace ? with & but there is still same issue.
I refer to this link
https://www.newthinktank.com/wp-content/uploads/2014/05/AppInventor22Blocks.png
I am confusing with last line
But my codes has this last line
The difference is Get and Reload
I could not find property web1.Get
Please
Regards
TIMAI2
5
Reload is the wrong block
1 Like
But sir there is not Get in events
Where to find it?
Regards
TIMAI2
7
You are looking in the Webviewer component, NOT the web component!
1 Like
Sir I followed this link
http://kio4.com/appinventor/340C_appinventor_mysqli.htm
Now my blocks looks like this
https://lettered-manners.000webhostapp.com/cng_insert.php
When I click Submit button then it show this error message
On the other side my code work here
What I am doing wrong now.
Please
TIMAI2
10
You do not appear to have any spaces in your url (orden), so remove the replacement block.
Also, test the Web1.Get url with the same one your tried in the browser ?
1 Like
Thanks for all participants, now my codes work fine, I have following blocks
I have a little question again
If data has been saved then there will be Notifier like
Data saved successfully
Please help me to show notifier
Regards
TIMAI2
12
Use the web.gottext event block to return the response content from the server. Display this in your notifier
About replace text...
Instead of using: data-->replace all text
try using:
Web2.Url ---> Web2.UriEncode ----> data
Web2.Get
Sir there is not Web2.UriEncode
From where to find it?
the url and parameters to be connected with ?, and each parameter connected with &.
But in your photo I only see &.
it should be like this:
http://aa.com?bb =cc&dd =ee&ff=gg
system
Closed
18
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.