You have asked three questions here. First, you could use the lua.socket library and open the MySQL database directly, but you would have to be very familiar with socket communications and the MySQL packet protocols, which even with my years of experience writing socket code, is not a project I would want to tackle, when a few lines of PHP will bridge the gap. I would recommend using a PHP layer in between, even if you’re only going to have your app access it.
Do you need a username/password? I suppose the technical answer is No, but do you really want anyone calling your script on your server and setting player scores? You don’t need it to get a list of scores. But for any script that writes you want to protect your database from being hacked.
Finally, the blog post was not a complete tutorial on saving scores. It was to show you how you could get started with PHP, MySQL and Corona. It’s up to you to figure out the rest. You should spend time learning how HTTP GET requests work, how parameters are passed as part of the URL.
$query = ‘INSERT INTO player (playername,playerscore) VALUES ("’.mysql_real_escape_string($playername).’","’.mysql_real_escape_string($playerscore).’")’;
$dbresult = mysql_query($query, $link);
if (!$dbresult) {
sir forget na previous question…
this is my last question…
when i used insert statement why null value to store…
this my main.lua
local myNewData
local json = require (“json”)
local decodedData
local playerName = “sos”
local playerscore = “200”
local function networkListener( event )
if ( event.isError ) then
print( “Network error!”)
else
myNewData = event.response
print ("From server: "…myNewData)
decodedData = (json.decode( myNewData))
– SaveData()
end
end
–end
just before you call mysql_query($query). You can run this in your browser to make sure its working. In your Corona App, print your URL value just before you call network.request(). Copy that URL to a web browser’s location bar to run your script fro the browser to see your output.
It has to get a response from the server first, so depending on the speed of the server and the amount of data being returned, the speed of the response will vary.
You should read up on networking before jumping in to the deep end