Code snippet for saving a key-value pair in gamemaker. Data is saved in the file data.dat. Works for all platforms.

Saving:

mKey="myKey";
mValue="myValue";
mMap = ds_map_secure_load("data.dat");
if (mMap==-1){
   mMap=ds_map_create();
} 

if (!ds_map_exists(mMap, mKey)){
   // add the key-value 
   ds_map_add(mMap, mKey, mValue);
} else {
   // replace the value for the key
   ds_map_replace(mMap, mKey, mValue);
}

ds_map_secure_save(mMap, "data.dat");
ds_map_destroy(mMap);

Loading:

mKey="myKey";
mValue="default value";

mMap = ds_map_secure_load("data.dat"); 
if (mMap==-1){
mMap=ds_map_create();
}
if (ds_map_exists(mMap, key)){ mValue=ds_map_find_value(mMap, key); } ds_map_destroy(mMap);



<?php 

function GetDbConnection(){ 

  $servername = "localhost"; 
  $username = "user"; 
  $password = "password"; 
  $dbname = "myDB"; 
  $conn = new mysqli($servername, $username, $password, $dbname); 
  if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
  } 
  return $conn;
}

function ListAllFromQuery($conn,$sql){
      
  $mArr = array();
  $result = $conn->query($sql);
  if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
      array_push($mArr, $row);
    }
  }
  return $mArr;
}


$conn = GetDbConnection();
$list =ListAllFromQuery($conn,"SELECT * FROM tblUser ORDER BY id;");
$output="";

for($i = 0; $i < count($list); $i++) { 
  $currentUser= $list[$i]; 
  foreach($currentUser as $key => $key_value) {
    $output.= $key . " = " . $key_value;
    $output.= "<br>";
  }
  $output.= "<hr>";
}

$conn->close();

echo $output;

?>