So im fairly new to coding, and have just started on a project for fun. I try to build a RPG game, and i have got to the point where players can fight and take damage. So i want to add a passive health regeneration.
So i was thinking that i would use a conjob to request a php file every 10min and update all players HP with +10.
What i have got with my very poor MySQL knowlege is;
<?php
/*
* hp_reg.php, auto updater +10hp to players.
*/
//DATABAS CONNECTION
$dbserver="my";
$dbusername ="db";
$dbpassword ="conection";
$db ="information";
//CREATE CONNECTION
$conn = new mysqli($dbserver, $dbusername, $dbpassword, $db);
$query = "SELECT health FROM users";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($query);
$newhp = $result + 10;
$sql = "INSERT INTO users(health) VALUES ($newhp)";
Wich clearly will not work at all! Any tips on what to change in order to get it to work? All pointers are much appreciated.