Stalingrad Posted November 6, 2008 Share Posted November 6, 2008 Hello. I'm trying to program a simple game that you can earn credits from. The only problem is that when it runs the PHP code to give the winner their credits, it inserts the amount they won as their credits. I want it to add the new amount to their existing credits. Would somebody please tell me where I'm going wrong? Here's my code: <?php include("../config.php"); $jquery = mysql_query("SELECT * FROM drawjackpot WHERE id='1'"); while($jrow = mysql_fetch_array($jquery)) { $jackpot = $jrow['jackpot']; } $count = mysql_num_rows(mysql_query("SELECT * FROM dailydraw")); $random = rand(1,$count); $query = mysql_query("SELECT * FROM dailydraw WHERE drawid='$random'"); while($row = mysql_fetch_array($query)) { $winner = $row['username']; } mysql_query("UPDATE drawjackpot SET winner='$winner'"); mysql_query("UPDATE users SET credits='credits'+$jackpot WHERE username='$winner'"); // Here's the line for adding the credits. mysql_query("INSERT INTO messages (userto, userfrom, subject, body, datesent, status) VALUES ('$winner', '', 'Congradulations!','Congradulations! You have won today's Daily Draw!', '$thedate', 'Unread'"); echo "$random $ubspace $winner $ubspace $count $ubspace $jackpot"; ?> Any help is greatly appreciated, and thank you in advance! =] Quote Link to comment Share on other sites More sharing options...
trq Posted November 6, 2008 Share Posted November 6, 2008 Sorry, I realise you must be new but, I've got to say.... that is some of the worst code I've seen, but anyway.... Change this query.... UPDATE users SET credits='credits'+$jackpot WHERE username='$winner' to.... UPDATE users SET credits=credits+$jackpot WHERE username='$winner' Quote Link to comment Share on other sites More sharing options...
Stalingrad Posted November 6, 2008 Author Share Posted November 6, 2008 Thanks a bunch! =] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.