please, have a look here; and thanks all! I am trying to create a system for upgrading buildings in my game. I made my upgrade div same for all buildings. When player click the build (div) run a function to appear a hide div filled by ajax post with the costs of upgrading. The class 'name'(same with the building name from db) of the div is sent to a php to get the required data. It works fine untill now... I added a click event to a button that should send the div 'name' into another php which should do the upgrade operation and echo "correct" in response ajax field. But when i click the btn, it show no log error... Error: SELECT ress1,ress2 FROM cost_cladiri WHERE building = 'camp_1' (I ve inserted a name of building from db instead of the variable(div name) to access the php directly, but the same error... Here is my ajax and my php
function getbuild(e) {
$.ajax({
type: 'post',
url: '../account-handeling/get_cost_upgrade.php',
data: {
building: e.className,
},
success: function (response){
$('#display_cost').html(response);
$("#increase").click(function(){
$.ajax({
type: 'post',
url: '../account-handeling/upgrade_handle.php',
data: {
building: e.className,
},
success: function (response){
$('#display_cost').html(response);
}
});
})
}
});
}
upgrade_handle.php
if(!isset($_SESSION))
{
session_start();
}
$dbserver = "localhost";
$dbusername = "root";
$dbpassword = "";
$db = "worlddomination";
$conn = mysqli_connect($dbserver,$dbusername,$dbpassword,$db);
if ($conn->connect_error)
{
die("No connection:".$conn->connect_error);
}
$username = $_SESSION['username'];
//$buildcost = $_POST['building'];
$sql = "SELECT ress1,ress2 FROM cost_cladiri WHERE building = 'camp_1'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($result);
$ress1 = $row['ress1'];
$ress2 = $row['ress2'];
if($conn->query($sql) === TRUE){
echo "$ress1";
}
else{
echo "Error: ".$sql."<br/>".$conn->error;
}
What i ve done wrong? Thanks!!!