I tried putting if($qotw == '1') instead of if(qotw = '1') but in that case only the second statement is executed and not the first (the message is displayed but the 'cash' and 'qotw' does not increase.
Please help me fix this so that BOTH statements will execute at the appropriate times. Thanks!
Code: Select all
<?php
$con=mysqli_connect("localhost","users","password","users");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if($qotw = '1')
{
mysqli_query($con,"UPDATE users SET cash = cash + $scash
WHERE username = '". $_SESSION['username'] . "'");
mysqli_query($con,"UPDATE users SET qotw = 1 + qotw
WHERE username = '". $_SESSION['username'] . "'");
}
if($qotw = '2')
{
echo "You have already attempted this question.";
}
mysqli_close($con);
?>