Jump to content
MakeWebGames

Player Purchasable Ads


TheMasterGeneral

Recommended Posts

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!!

Link to comment
Share on other sites

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 by KyleMassacre
Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...