How could I insert datas on a remote db without downloading the file and uploading it again?
thank you,
Andrea [import]uid: 63063 topic_id: 34578 reply_id: 334578[/import]
How could I insert datas on a remote db without downloading the file and uploading it again?
thank you,
Andrea [import]uid: 63063 topic_id: 34578 reply_id: 334578[/import]
I guess you use a php script on your server?
Here’s a sample how I update a highscore for my Trivia game:
[code]
<?phpThank you! That’s a good idea!
But using this method I should open an url from my app using system.openURL("http://www.mywebsite.com/index.php?Name=\*\*\*&Score=\*\*\*&Device=\*\*\*")
which opens a page in the browser…and if I want to open an url without displaying the browser page how could I do that?
Thanks a lot,
Andrea
[import]uid: 63063 topic_id: 34578 reply_id: 137507[/import]
Look at the network.request() API call. Also see this blog post:
http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/ [import]uid: 199310 topic_id: 34578 reply_id: 137527[/import]
Thank you rob! Your blog helped me a lot! [import]uid: 63063 topic_id: 34578 reply_id: 137605[/import]
I guess you use a php script on your server?
Here’s a sample how I update a highscore for my Trivia game:
[code]
<?phpThank you! That’s a good idea!
But using this method I should open an url from my app using system.openURL("http://www.mywebsite.com/index.php?Name=\*\*\*&Score=\*\*\*&Device=\*\*\*")
which opens a page in the browser…and if I want to open an url without displaying the browser page how could I do that?
Thanks a lot,
Andrea
[import]uid: 63063 topic_id: 34578 reply_id: 137507[/import]
Look at the network.request() API call. Also see this blog post:
http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/ [import]uid: 199310 topic_id: 34578 reply_id: 137527[/import]
Thank you rob! Your blog helped me a lot! [import]uid: 63063 topic_id: 34578 reply_id: 137605[/import]
Hi Rob;
I read your tutorial thanks, however I’m still having trouble grasping how I would update a value - say the user’s score - in the remote database. Would it be using the network.request or could we simply set the URL as the directory for the system.pathForFile and open something like a io.open read write sort of thing?
I’m so confused…
Does the GET also update the info on the remote database?
Wow, I need more coffee!
You would write a PHP script, maybe called “setscore.php” that takes the parameters you need to pass (playername, score, etc.). That script will either read them as a GET value from the URL or a POST value, depending on your preferences. I would assume your database would probably use playername or something similar as a key and once you have the variables in PHP do an SQL query like
$query = “REPLACE scores (playername, score) VALUES (” . $playername . ", " . $score . “)”;
or something like that and then have mySQL run the query on $query.
Ok thanks for your time Rob I appreciate it…
I think I’m starting to get it now, so the PHP script will take what it needs from something like:
http://servername.com/setscore.php?deviceid="…deviceID…"&score="…score --if I were using device ID as a key.
and the PHP script will do the updating of the values…
Too the PHP docs… :ph34r:
Wait… is there a sample of a PHP script that has the update function in it?
I will check around some more.
Thank you again.
LOL wow I’m dumb today… yeah the script up there ^^
My apologies for the dumbness!
:rolleyes:
Hi Rob;
I read your tutorial thanks, however I’m still having trouble grasping how I would update a value - say the user’s score - in the remote database. Would it be using the network.request or could we simply set the URL as the directory for the system.pathForFile and open something like a io.open read write sort of thing?
I’m so confused…
Does the GET also update the info on the remote database?
Wow, I need more coffee!
You would write a PHP script, maybe called “setscore.php” that takes the parameters you need to pass (playername, score, etc.). That script will either read them as a GET value from the URL or a POST value, depending on your preferences. I would assume your database would probably use playername or something similar as a key and once you have the variables in PHP do an SQL query like
$query = “REPLACE scores (playername, score) VALUES (” . $playername . ", " . $score . “)”;
or something like that and then have mySQL run the query on $query.
Ok thanks for your time Rob I appreciate it…
I think I’m starting to get it now, so the PHP script will take what it needs from something like:
http://servername.com/setscore.php?deviceid="…deviceID…"&score="…score --if I were using device ID as a key.
and the PHP script will do the updating of the values…
Too the PHP docs… :ph34r:
Wait… is there a sample of a PHP script that has the update function in it?
I will check around some more.
Thank you again.
LOL wow I’m dumb today… yeah the script up there ^^
My apologies for the dumbness!
:rolleyes: