Web Hosting Talk







View Full Version : Urgent: need a small script to store/read a string (Adsense ID's)


Quintox
10-23-2007, 11:27 AM
I suck at programming. I need a script where I can save Adsense ID's, and then have them randomly (or in order) be 'inserted' into the proper place in the Adsense code in my .php file. Everytime a page is loaded so that it shows a different ad each time.

I know this must be simple, but can someone whip it up real fast for me?

tanfwc
10-23-2007, 11:31 AM
I think you forget to state which programming language this is in :)

Quintox
10-23-2007, 11:32 AM
.php sorry :)

berumelu
10-23-2007, 11:47 AM
Hi,

You can use random generated function within PHP code.

Example, if you have an ad flash file with numbered id like "ad1.swf" and "ad2.swf" use this:


$adid = mt_rand(1, 2);
$adswffile = "ad".$adid.".swf";


Then you can insert the flash object.

Hope this could help.


Regards,

Luis Berumen

Jatinder
10-23-2007, 11:57 AM
I need a script where I can save Adsense ID's, and then have them randomly (or in order) be 'inserted' into the proper place in the Adsense code in my .php file

Which ID are you referring to? Adsense code has different variables like google_ad_width, google_ad_height, google_ad_format etc. which control the type of ad to display.

You will need to specify these variables to change the ad format.

Or are you referring to publisher ID? That is, you want to display ads for different publisher accounts.

Quintox
10-23-2007, 12:00 PM
Yes publisher ID's

Jatinder
10-23-2007, 12:10 PM
I doubt anyone will do this script for free. If you are willing to do the coding, I can provide you the guidance you need.

Quintox
10-23-2007, 12:12 PM
I didn't know how complicated the coding was. It sounds simple but I guess it's not. I can probably figure out how to do it in Vbasic (lol) but not PHP. Couldn't a file be made where I copy/paste the ID's into, and then call the file in my Adsense code in the index.php? I don't know how to randomly call a number though each time page reloads though....
There is a free script that does this but I can't figure out how to do it for google
http://www.cj-design.com/products/free_downloads/php_scripts/cjadrotator

Jatinder
10-23-2007, 12:30 PM
1. Store publisher IDs in a file. One id per line.
2. Use file() to read these publisher IDs into an array.
3. Use array_rand() to select a ID randomly.
4. Use this ID in the adsense code.

Quintox
10-23-2007, 12:43 PM
I will look up how to do all that Jat, thank you (I pretty much don't know PHP at all) lol

anon-e-mouse
10-24-2007, 02:55 AM
Thread closed by request.