I’m not an expert on PHP and MySQL but my guess would be that it simply does not receive the index ‘gscore’ from GDevelop.
The problem could be either the server doesn’t allow the call made by GDevelop or you didn’t setup the request in GDevelop properly or your firewall block the connection.
First make sure your firewall allow the game and GDevelop to connect.
Then make sure everything is set in GDevelop the way it supposed to be. You are expecting to receive ‘gscore’ so make sure you have entered in GDevelop “gscore=”+value as request
The value can be anything really but make sure you convert it to string in case it an integer using the ToString() expression.
For example: “gscore=”+ToString(Variable(score))
Next, make sure you have the “POST” method enabled
Finally, make sure you have the host and the page setup correctly.
The host field should NOT include any folders or pages. For example if you have a gdevelop folder in your web root directory and you have the php file inside the gdevelop folder, it should look like this to send a value from a variable to a php file:
[code]Host:
“http://www.something.com” or “http://localhost”
Path to page:
“/gdevelop/insertScore.php”
Request body content:
“gscore=”+ToString(Variable(score))
Method:
“POST”
[/code]
Then, the php code should look something like this to receive the value and insert it in to the database:
[code]<?php
//connect to database
$database = mysqli_connect(‘localhost’, ‘username’ , ‘password’ , ‘database_name’);
//if connection to database is successful, then get index ‘gscore’ sent from GDevelop and insert in to the database
if($database){
$score = $_POST['gscore'];
if($score){
$query="INSERT INTO table_name(column_name) VALUES ($score)";
mysqli_query($database, $query);
}else{
die(mysqli_error());
}
}else{
die(mysqli_error());
}
?>[/code]
If it still doesn’t work, probably it is the server configuration, I’m not very experienced on this, so I can’t offer help.
The only thing I can suggest to try is to add an .htaccess next to the PHP file which is supposed to receive the data ‘gscore’ and make the MySQL query and enter the following in to the .htaccess file:
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"