Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Random Images (http://www.mysidiaadoptables.com/forum/showthread.php?t=2472)

SilverDragonTears 10-25-2011 12:49 PM

Random Images
 
How can I get a random image to pop up on the adopts pages, not everytime it loads.... just randomly, and random pictures? I want to make a sort of trick or treat hunt for my members.Once they see an image they click it and it is added to a special page they can access. I know how to do all that, I just don't know how to get the random images to show up.

What if I made a new table called treats? and inserted all the images into it. Then on the adopts page I could make them echo out randomly. Then once it's clicked, run a query that inserts the image into a new field in the users table. But how could I make the image NOT show up every time the page is clicked?

mapleblade 10-25-2011 01:02 PM

you can try this

PHP Code:


<?php

$treat 
secure($_GET['treat']);

if(!empty(
$_GET['treat'])){

$success 0;

if(
$treat == 0){

// query for adopt?
$success 1;
}
elseif(
$treat == 1){

// query for adopt?
$success 1;
}
elseif(
$treat == 2){

// query for adopt?
$success 1;
}
elseif(
$treat == 3){

// query for adopt?
$success 1;
}
elseif(
$treat == 4){

// query for adopt?
$success 1;
}
elseif(
$treat == 5){

// query for adopt?

$success 1;
}

if(
$success == 1){
echo 
"You have successfully collected this treat!";

}
}else{

$show rand(0,100);

$random rand(0,5);

// 1 on 100 chance to show an image

if($show == 1){

//random image, modify the $random etc, and add more if ya want
if($random == 0){

$image "http://image.com/lol.png";
$link "http://lol.com/adopt.php?id=bl1a";
}elseif(
$random == 1){

$image "http://image.com/lol1.png";
$link "http://lol.com/adopt.php?id=bla";
}
elseif(
$random == 2){

$image "http://image.com/lol1.png";
$link "http://lol.com/adopt.php?id=bla";
}
elseif(
$random == 3){

$image "http://image.com/lol1.png";
$link "http://lol.com/adopt.php?id=bla";
}
elseif(
$random == 4){

$image "http://image.com/lol1.png";
$link "http://lol.com/adopt.php?id=bla";
}
elseif(
$random == 5){

$image "http://image.com/lol1.png";
$link "http://lol.com/adopt.php?id=bla";
}




// now actually paste it

echo "<a href='".$link."'><img src='".$image."' /></a> <font color='red'>YOU FOUND A TREAT! CLICK HERE TO COLLECT IT!</font>";

}
}

?>

all i worry about is spamming treats, you could put some security on it, so it can only be gotten once a time or something :)

SilverDragonTears 10-25-2011 01:06 PM

Ooooo thank you!! Will try this now =)


EDIT: Ok so maybe I should know how this works. I added in some images and when I refresh I'm getting a broken image every time.

How about show a random image every 10 minutes?

mapleblade 10-25-2011 01:19 PM

i editted the thing a lil bit, uhm check the echo i did, maybe theres an typo in it, and i think it would require cronjobs or a time stamp in a database table, and delete it every 10mins after it was entered.

Edit: u can experiment with it, i really gotta go back to my homework for tomorrw x3

mapleblade 10-25-2011 01:24 PM

i saw the error on your site, fixed

SilverDragonTears 10-25-2011 01:26 PM

[s]Now I get this... Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home/robynswo/public_html/myadopts.php on line 19[/s]

LoL =) Ok so I'm not good with cron jobs.... what would I need to do?

edit:
actually I'm not seeing the image at all... I changed echo to $article_content .=" too and still nothing.. hmm

mapleblade 10-25-2011 01:28 PM

i already fixed it for u in my post, it should work now

mapleblade 10-25-2011 01:33 PM

i found one, it looks like a vampire :D, somehow it changed ur font size? :o?

btw link should be myadopts.php?treat=id

SilverDragonTears 10-25-2011 01:36 PM

YEa I fixed that part. Thanks for the start! I'll play with it a bit today. If I can't get it working at least I can probably fix it before next Halloween LOL


I've yet to see one O.o

Ha! Got one.. now to figure out how to save it to a user and show it on a new page. ugh.

mapleblade 10-25-2011 01:47 PM

maybe you're better of with using the adopt.php link and limit it to one per acc

SilverDragonTears 10-25-2011 01:48 PM

what do you mean? (don't let me keep you from homework ^^)

mapleblade 10-25-2011 01:52 PM

well ignore the top part (the if(!empty($treat)){) completely and use the adopt.php for the queries and stuff, i think it would be quicker and safer then recoding the whole thing just for some treats :3

SilverDragonTears 10-25-2011 01:53 PM

oy... so basically let them adopt a treat? How do I manage that?

mapleblade 10-25-2011 01:56 PM

add an adoptable with the treat and use the adopt.php?id= // here your adopt number
as link, and put restrictions on it while your adding the adoptable.

SilverDragonTears 10-25-2011 02:22 PM

Grrr the id= is blank >.>

mapleblade 10-25-2011 02:28 PM

just use the doadopt?id= link with the id already in it at $link

mapleblade 10-25-2011 02:30 PM

so example: $link = "http://silvadopts.com/doadopt.php?id=86";

SilverDragonTears 10-25-2011 02:32 PM

ahh can i use any number?

mapleblade 10-25-2011 02:43 PM

use the number from the adoptable u made (adoptable ID from adopt.php)

mapleblade 10-25-2011 02:51 PM

illl do it detailed:

1. create all treats as adoptables and make them promo code with something randomly unguesabble, and put that it can only be adopted once PER ACC, so not the first option
2. use the promo key and adopt it, you will see something like this: doadopt.php?id=1&name=lol&promocode=abcdefghijklmn opqrstuvwxyz&Submit=Adopt+Me

take the first part: doadopt.php?id=1 and use it in ur link

so it would be site.com/doadopt.php?id=1

SilverDragonTears 10-25-2011 03:04 PM

trying to test with just the skeleton and he won't come up.... stubborn treat. must be a trick >.>

mapleblade 10-25-2011 03:14 PM

somehow i got some errors and ur site is messed up for me :o?



Warning: session_start() [function.session-start]: open(/tmp/sess_c3cf5ec414dabe40b0a17d180d683ad5, O_RDWR) failed: Permission denied (13) in /home/robynswo/public_html/inc/functions.php on line 21

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/robynswo/public_html/inc/functions.php:21) in /home/robynswo/public_html/inc/functions.php on line 21


maybe 777 your /tmp folder?

SilverDragonTears 10-25-2011 03:17 PM

it does that sometimes... it is 777... i've talked to my web host and am waiting for it to happen to me again so I can screen shot it.

mapleblade 10-25-2011 03:19 PM

k, i cant manage to get any treats x3, maybe remove restriction on how many u can adopt, but it could be spammable, because if you get the same treat again, you cant adopt one anymore.

SilverDragonTears 10-25-2011 03:22 PM

nah, i don't want them getting more than one so i'll keep it as is. you=awesome! thanks so much for your help! eventually when i DO get the skeleton and it works i can then make the show page which will be the easy and fun part!

mapleblade 10-25-2011 03:32 PM

haha good luck :P

SilverDragonTears 10-25-2011 06:15 PM

well it was working but now it says invalid id =/

mapleblade 10-26-2011 12:44 AM

its because you already have 1 of the adoptables, or you accadently set 1 adoptable instead of 1 adoptable per acc.

SilverDragonTears 10-26-2011 12:57 PM

it's working now, however it's allowing more than one to be adopted even though i set the conditions.


All times are GMT -5. The time now is 09:19 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.