War_Hero Posted February 21, 2011 Share Posted February 21, 2011 Hi all! It's been ages since I last posted on here, so I thought I'd contribute a feature I've been working on. I searched for lottery mods already on here, and unless I didn't look properly, I couldn't see any free ones that actually allows the user to choose their own numbers. Description: Upon going onto lottery.php, the user will be presented with a table of checkboxes, numbered 1 to 46. The info above the table will ask them to select 6 of their own numbers or press Lucky Dip to have them randomly selected for them. This feature uses Javascript. If the user opts to select the numbers themselves, they cannot press Buy Ticket until 6 boxes have been ticked. When 6 have been ticked, all other boxes become disabled and they can buy the ticket. If a box is then unticked, the others become enabled and the Buy Ticket button becomes disabled. The Lucky Dip randomly selects 6 numbers, ticks the correct boxes and disables them, and enables the Buy Ticket button. A reset button is provided to clear any boxes ticked, whether manually or by the Lucky Dip. The price of each lottery ticked can be edited via the Staff feature I have made, so no edit in the file will be needed. Also, the ticket limit can also be altered via the staff feature. The lottery numbers are drawn (with my cron settings) every Saturday night at 20:00. If no tickets match all 6 numbers, there will be a rollover. This will continue to happen until all 6 numbers are matched. Talking of the cron, the numbers are drawn from the cron_lottery.php file. Right, time for the installation...it shouldn't be too difficult: Step 1 Run these SQLs: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Step 2 Create a new cron (however it is you do it, cPanel, Direct Admin, etc) with these values: Minute: 0 Hour: 20 Day of Month: * Month: * Day of Week: 6 Command: Erm, yeah! :) Step 3 Create a file called cron_lottery.php: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Step 4 Create a file called lottery.php: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Step 5 Create a file called staff_lottery.php: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. And you're done. :) I will (hopefully) be adding more to this feature, for free. I intend on improving the staff feature, creating a way in which users can see previous lottery results and also implement other games, such as the Dream Number, etc. I have tested this feature, and it works. But as always, if there are any bugs, please report them here and I will fix them (or attempt to!). And please feel free to contribute any other ideas. If you have any questions about the feature, please don't hesitate to ask. :) Quote Link to comment Share on other sites More sharing options...
Djkanna Posted February 22, 2011 Share Posted February 22, 2011 Looks good, well done War_Hero. :) Quote Link to comment Share on other sites More sharing options...
Zan Posted February 22, 2011 Share Posted February 22, 2011 Nice work pal...;) Quote Link to comment Share on other sites More sharing options...
danger boy Posted February 22, 2011 Share Posted February 22, 2011 Looks good and sounds great! Well done. Quote Link to comment Share on other sites More sharing options...
Sethenor2 Posted February 22, 2011 Share Posted February 22, 2011 Sounds great that can be added to my free mod folder thanks for the share ! Quote Link to comment Share on other sites More sharing options...
War_Hero Posted February 22, 2011 Author Share Posted February 22, 2011 Thank you all for the comments. :) I hope you all like the feature. If/when one of you install it, please let me know if all the aspects of the mod work. It works on my end, I'd just like to ensure it will work elsewhere. :) Quote Link to comment Share on other sites More sharing options...
Mystical Posted February 22, 2011 Share Posted February 22, 2011 Thank you all for the comments. :) I hope you all like the feature. If/when one of you install it, please let me know if all the aspects of the mod work. It works on my end, I'd just like to ensure it will work elsewhere. :) When inserting this > INSERT INTO lotteryDetails (50,10,0); Getting this > #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 '50,10,0)' at line 1 I am not a coder obviously.... :D Think I figured that out on my own... All installed and one slight problem Pick six numbers...click buy ticket...and this happens: "You either didn't select any numbers or you didn't select 6 numbers." It does buy tickets if you are using the "Lucky Dip" feature however. Other than that it is pretty nice! :) Quote Link to comment Share on other sites More sharing options...
War_Hero Posted February 22, 2011 Author Share Posted February 22, 2011 The first error is fixed. I forgot to include the VALUES before the (50,10,0). Doh. Hmm. By the sounds of it, it would seem the Javascript isn't working. You shouldn't be able to submit the ticket unless you have selected 6 numbers. It works for me. Hmm..... Quote Link to comment Share on other sites More sharing options...
danger boy Posted February 22, 2011 Share Posted February 22, 2011 i have added this mod to my game and works perfectly fine. Just have to wait till saturday to see if the jackpot is credit to the lucky user ;). All in all, its a great mod! Thanks! Quote Link to comment Share on other sites More sharing options...
Mystical Posted February 23, 2011 Share Posted February 23, 2011 i have added this mod to my game and works perfectly fine. Just have to wait till saturday to see if the jackpot is credit to the lucky user ;). All in all, its a great mod! Thanks! Can you clue the rest of us on how you got it working? Still the same for me Pick six numbers...click buy ticket...and this happens: "You either didn't select any numbers or you didn't select 6 numbers." No change.... I even used different browsers and still no luck. :( Quote Link to comment Share on other sites More sharing options...
danger boy Posted February 23, 2011 Share Posted February 23, 2011 I added the file that has been given above. It worked fine for me the first time :) Quote Link to comment Share on other sites More sharing options...
War_Hero Posted February 24, 2011 Author Share Posted February 24, 2011 i have added this mod to my game and works perfectly fine. Just have to wait till saturday to see if the jackpot is credit to the lucky user ;). All in all, its a great mod! Thanks! Can you clue the rest of us on how you got it working? Still the same for me Pick six numbers...click buy ticket...and this happens: "You either didn't select any numbers or you didn't select 6 numbers." No change.... I even used different browsers and still no luck. :( I might be able to provide some assistance if I can see the problem first hand. Because if you have copied and pasted the code as it is, which I'm assuming you have done, then there should be no problems. Just a quick question: when you press Lucky Dip, do all of the checkboxes become disabled and the Lucky Dip button become disabled? Quote Link to comment Share on other sites More sharing options...
Ishraq Posted February 25, 2011 Share Posted February 25, 2011 when you click lucky dip. it selects 6 numbers for you and when you click buy ticket. IT WORKS. However, if you pick the numbers yourself, it gives that error saying "You either didn't select any numbers or you didn't select 6 numbers." Quote Link to comment Share on other sites More sharing options...
War_Hero Posted February 25, 2011 Author Share Posted February 25, 2011 It must be something you're doing while installing it, as it works perfectly fine for me. I just don't understand why the picking of numbers doesn't work for you, or Mystical. Hmmm. ?( Quote Link to comment Share on other sites More sharing options...
Mystical Posted February 26, 2011 Share Posted February 26, 2011 when you click lucky dip. it selects 6 numbers for you and when you click buy ticket. IT WORKS. However, if you pick the numbers yourself, it gives that error saying "You either didn't select any numbers or you didn't select 6 numbers." Exactly the same for me....... It looks like a great mod but I removed it. When it gets sorted I will use it for sure. :) Copy and pasted the codes exactly. All other mods have worked except for this one so I dont think it is something I did. I even spelled language right because it is spelled wrong in your code thinking that might fix it but it did not... Quote Link to comment Share on other sites More sharing options...
jay-dogg2009 Posted February 26, 2011 Share Posted February 26, 2011 the issues with not being able to selcect your own numbers lies within the globals.php with the $val $val = trim($val); //Removes tags html/php $val = strip_tags($val); //Add inverted bars to a string $val = addslashes($val); Thats what the issues are i removed and tested and selecting you tickets work. so if any one can shred some light on how to over come this? Quote Link to comment Share on other sites More sharing options...
War_Hero Posted February 26, 2011 Author Share Posted February 26, 2011 the issues with not being able to selcect your own numbers lies within the globals.php with the $val $val = trim($val); //Removes tags html/php $val = strip_tags($val); //Add inverted bars to a string $val = addslashes($val); Thats what the issues are i removed and tested and selecting you tickets work. so if any one can shred some light on how to over come this? Thank you for finding that out. This isn't the part with if(get_magic_quotes_gpc() == 0) { etc, is it? Because I don't have that bit of code in my own globals.php, I don't believe... Quote Link to comment Share on other sites More sharing options...
jay-dogg2009 Posted February 27, 2011 Share Posted February 27, 2011 no its now thats for securing input stripping back unwanted inject code. so you ca remve this and secure another way. Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted February 27, 2011 Share Posted February 27, 2011 I believe this $var code is one of those put this in your header and it will secure your site loada bollox! Remove it and yes you will find stuff now works as its a false sense of security that does more damage than good. Secure your code. If using mc2 then wait for 2.0.3 as its starting to look promising as a base foundation. Quote Link to comment Share on other sites More sharing options...
War_Hero Posted February 27, 2011 Author Share Posted February 27, 2011 I believe this $var code is one of those put this in your header and it will secure your site loada bollox! Remove it and yes you will find stuff now works as its a false sense of security that does more damage than good. Secure your code. If using mc2 then wait for 2.0.3 as its starting to look promising as a base foundation. Thank you for clearing that up for me. I had a slight feeling it was one of the 'add this and you will secure your site' sort of things. So anyone experiencing any problems with this feature, please comment out the header code with the $val and see if the lottery works. Please let me know how it goes. :) Quote Link to comment Share on other sites More sharing options...
CoRnNuB Posted March 8, 2011 Share Posted March 8, 2011 i get these errors after i install it can anyone help me Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 102 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 108 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 111 Quote Link to comment Share on other sites More sharing options...
War_Hero Posted March 8, 2011 Author Share Posted March 8, 2011 i get these errors after i install it can anyone help me Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 102 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 108 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/streets1/public_html/lottery.php on line 111 You haven't installed it correctly if you're receiving those errors. It seems like the tables, specifically lotteryDetails and lotteryTickets, aren't in your database. Make sure they are. I can't think of another reason as to why those errors would occur. Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted March 11, 2011 Share Posted March 11, 2011 Nice modification, glimpsed quickly over the code, and nice to see some one else using mysql_fetch_assoc() :) Quote Link to comment Share on other sites More sharing options...
Paul Evans Posted March 11, 2011 Share Posted March 11, 2011 Quote from MC v2.0 class file (mysql) function fetch_row($result=0) { if(!$result) { $result=$this->result; } return mysql_fetch_assoc($result); } Notice anything there... using mysql_fetch_assoc is the same as using $db->fetch_row i really do wish people would read things they code in. Quote Link to comment Share on other sites More sharing options...
War_Hero Posted March 11, 2011 Author Share Posted March 11, 2011 Quote from MC v2.0 class file (mysql) function fetch_row($result=0) { if(!$result) { $result=$this->result; } return mysql_fetch_assoc($result); } Notice anything there... using mysql_fetch_assoc is the same as using $db->fetch_row i really do wish people would read things they code in. I know this. :) I just use mysql_fetch_assoc in my mods so it's easier for others to convert to V1 or Lite. I know they could probably do a simple find and replace in their editor, but it's still easier. Also, my editor changes the colour of the mysql functions, so it helps me notice if I've misspelled one. :) 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.