but i do not understand what i am doing wrong and why it is not working ?
Seems like it connects with DB, but it wont update DB table.
My PHP code
<?php
$host = 'localhost';
$db_name = 'db_name';
$db_user = 'user';
$db_password = 'password';
$con = mysqli_connect($host, $db_user, $db_password, $db_name);
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
function _VoteReward($custom)
{
$sql = "UPDATE `users` SET `gold` = `gold` + 50000 WHERE `id` = '".$custom."' ";
mysqli_query($con, $sql);
}
$custom = $_POST["custom"];
$key = $_POST["key"];
$result = false;
if (($custom > 0) && ($key == 'key'))
{
$result = true;
_VoteReward($custom);
}
mysqli_close($con);
?>