Hello. I have tried to make a script that will update a user's 'points' if they post a correct answer. Unfortunately I can't get it to work. Could you help me out? <?php if (isset($_POST['answer'])){ if ($_POST['answer'] == 'answer){ $con = mysql_connect("XXXXXXXXXXXXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("b13_980789_db", $con); $username = $_SESSION['username']; $points = mysql_query("SELECT `points` FROM `b13_980789_db`.`users` WHERE `users`.`username` = '$username'"); $pointsTwo = $points + 3; mysql_query("UPDATE `b13_980789_db`.`users` SET `points` = '$pointsTwo' WHERE `users`.`username` = '$username'"); mysql_close($con); echo "Congratulations.";} } ?> Code (markup):
Yes, Try to change your mysql password as soon as possible. For your problem, check the session variable, and you may shorten your query like this: "UPDATE `b13_980789_db`.`users` SET `points` = points+3 WHERE `users`.`username` = '$username'" Code (markup):