Hello guys, I'm a newbie in php and stuff.. I'm trying to create a super simple base for a php and mssql website script for an mmo. Here's my code
These codes works just fine, the problem is that even when the player have less points then they actually need to buy the item, they still can buy it and their remaining point will be a negative value (example, -30) and that is the problem that I need to overcome.
This might be a really noob questions, but I don't know the correct keyword to use google to help me find the answer.. I hope any of you guys could help me with this. It is highly appreciated. Thank you in advance.
Code:
$id = $_SESSION['id_idx'];
$point = $_POST["point"];
$item = $_POST["item"];
$query = "UPDATE chr_log_info SET point = (point - '$point') WHERE id_idx = '$id'";
$result=mssql_query($query) or die("Error Here!");
$query2 = "insert tb_item(character_idx, item_idx, item_position, item_qposition, item_durability, item_shopidx) values(0, '$item', 240, 0, 1,'$id')";
$result2=mssql_query($query2) or die("Error Here!");
This might be a really noob questions, but I don't know the correct keyword to use google to help me find the answer.. I hope any of you guys could help me with this. It is highly appreciated. Thank you in advance.