Hi guys I am working on a small project for my site, the site of mine sells digital codes so I thought it would be fun to have a section where my customers can go and gamble for the chance to win a code..
So I have the main bulk of the application, currently the game works like the slots, you click play and 3 numbers are generated, each number = a prize you can win match 3 prizes and win a ... prize!
So the codes will be stored in a database and be shown on screen, and probably emailed to the winner, obviously I cant have the code sent out twice so I have a row called active, the code starts at 1 which is active and when it is sent out it is set to 0 inactive.
The codes are showing up fine but I need help setting the code to inactive, this is my first php project and I have little programming experience so I apologize if this seems quite a simple question
So anyway here is my code for retrieving the code from the database
$results = $conn -> query('SELECT code FROM orders WHERE active = 1 LIMIT 1 SET active = 0');
so as you can see if takes a code from orders if the code is set as active, but the last lin SET active = 0 gives me the error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET active = 0' at line 1' in C:\xampp\htdocs\Learning\0Casino\win.php:9 Stack trace: #0 C:\xampp\htdocs\Learning\0Casino\win.php(9): PDO->query('SELECT code FRO...') #1 {main} thrown inC:\xampp\htdocs\Learning\0Casino\win.php on line 9
Which I understand is due to poor syntax, can anyone tell me how to properly use the SET/ACTIVE properties?
Should I be doing this in another line or is it okay to have the code retrieved and deactivated on the same line?
Thanks in advance
Luke