TheMasterGeneral Posted January 27, 2015 Posted January 27, 2015 Mod Title: Player Purchasable Ads Info: Allows a player to post an ad in a newspaper, which lasts for three days. The ad costs, at minimum, 100K Cash (your main currency.) The more you pay, however, the higher you are ranked on the page. This Mod Comes With: 1 SQL Query 1 PHP 1 Cron (Too lazy to copy and paste? Click me for a download!) Call this whatever: [Default = playerads.php, will need to change a config value on line 15 if its different, however, the code has been set to allow use of custom file names] You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Execute this SQL You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add to day cron: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. That should be it. Questions or comments? Leave a reply here and I will get to it ASAP!! Quote
KyleMassacre Posted January 28, 2015 Posted January 28, 2015 (edited) Here's a tip for ya, you don't need the filename as long as it's in the same file like so: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. is the same as: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. also maybe you should reconsider some of your data types Int(11) and bigint(11) for some/most/all of those are not really reasonable and/or needed. You can get away with much smaller types. Just for reference int(11) can go to 2 billion And much higher if it's unsigned. http://dev.mysql.com/doc/refman/5.0/en/integer-types.html Another thing is maybe you can make use of timestamps instead of a cron? Edited January 28, 2015 by KyleMassacre Quote
KyleMassacre Posted March 25, 2016 Posted March 25, 2016 If you click the reply button the SQL will show up Quote
KyleMassacre Posted March 26, 2016 Posted March 26, 2016 You get the fatal error because $h is not included in the global list of variables inside the function and for the undefined indexes, that is exactly what the error says. Its not being checked if it exists before being used. Quote
KyleMassacre Posted March 27, 2016 Posted March 27, 2016 It's because it's checking those post keys before anything has been posted through the form. Arrays must be checked one way or another before being used. Depending on what you are looking for there are a couple of functions you can use. 1. isset(): Exactly what the function name says. It checks to see if a value is set to that array. 2. array_key_exists(): Checks to see if a key has been set to the array. i.e $array['key'] = 'value'; For when you come across the terminology key value pair or key => value pair. And more but these are the most used from what I have seen. And as you can see from the code (which is another argument I have seen) is that you are calling the global variable $_POST and assigning it a value before checking it. I could give you the answer on how to fix those but I want you to learn for yourself. But here are somethings to look for: 1. Do you want to check if a value is set to an array, or do you want to see if an array key exists? 2. Do you want to overwrite the global variable $_POST with data since PHP knows that it should be looking for data posted during run time? For me personally I would do something that had a mix of all of this: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Quote
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.