Log in

View Full Version : while statements, eval, and only one result showing :(


dv6cougar
05-15-2003, 12:50 PM
hey guys, i'm using the Template Hack, mucho props to whomever made that, it's a great hack!

however, i'm trying to make a raffle like hack with this, so far i'm not doign to bad :)

this would be my first attempt at a hack.

i have this in my code

//check to see that $id is not set
if(!isset($id)) {
$raffle = $DB_site->query("SELECT * FROM raffle_list WHERE status='current'");
while($raffleql = $DB_site->fetch_array($raffle)) {

$raftitle = $raffleql['title'];
$rafid = $raffleql['id'];
eval("\$ticketid = \"".logiciangettemplate('ticketid')."\";");
}//end while
}//end $id is not set


and then i have my template set to use $ticketid, which works great :)

but then the ticketid tempalte looks like this


<a href="show.php?pg=raffle&id=$rafid">$raftitle</a>

the $rafid and $raftitle work like a charm, however, if i have 2 raffles i want to show up it only shows one :(

how do you make the while statement work correctly? i know you can do it, since teh forumhome and forumdisplay does it :)

thanks alot ;)

colicab-d
05-15-2003, 01:14 PM
yeah ive had this prob before, with a simple shout box i made, when i eval`d i could only get 1 result showing

JulianD
05-15-2003, 01:20 PM
After a quick look to your code, try to replace this:


eval("\$ticketid = \"".logiciangettemplate('ticketid')."\";");


for this:


eval("\$ticketid .= \"".logiciangettemplate('ticketid')."\";");

dv6cougar
05-15-2003, 01:21 PM
hmm ok i even tried it within my original raffle template and not using $ticketid and what not as seperate templates....


any help would be great here :) usually there will only be one raffle but there may be more then 1 sometimes :) thanks for your input

dv6cougar
05-15-2003, 01:27 PM
Today at 03:20 PM JulianD said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=395441#post395441)
After a quick look to your code, try to replace this:


eval("\$ticketid = \"".logiciangettemplate('ticketid')."\";");


for this:


eval("\$ticketid .= \"".logiciangettemplate('ticketid')."\";");



actually that would make sense .= so it takes more as needed :)

thanks!

JulianD
05-15-2003, 01:28 PM
No problem :)

filburt1
05-15-2003, 02:00 PM
Be uber-certain to either unset() or set to "" $ticketid first to avoid HTML injection.

Boofo
05-15-2003, 02:16 PM
Would this be the same thing then?

$pollrun = "";
unset($pollrun);

even though the variable hasn't been declared yet?

filburt1
05-15-2003, 02:24 PM
Either:

unset($pollrun); // i like because it happens to free memory too

or

$pollrun = "";

works. Remember with vB2, register_globals is explicitly turned on which is the biggest security hole known to mankind.

Boofo
05-15-2003, 02:26 PM
Which one would you have to use with register_globals turned off?

Dean C
05-15-2003, 02:32 PM
The simple way to learn it is to output the bits of data in the while loop can call the actual template outside of the while loop :)

- miSt

dv6cougar
05-15-2003, 04:33 PM
haha, thanks everyone...... i usually do $poll = ""; and such, i have done alot of little things to my forum ;)

i made a script that uses the forum usernames and passwordst o login with :)

a new question.... i have 8 different styles, and 5 out of them are very different from the rest.. so how would I go about focring a style? i'd wanna use a styleid but how do you force it... oh wait nm!


//set varaible for style that you wanna overgiht

$overstyle = "1";

$styleid = $overstyle;


would that work?

dv6cougar
05-15-2003, 04:38 PM
or wait i could even use
$session['styleid']

which would be better?!

thanks :)

filburt1
05-15-2003, 04:54 PM
I'm not sure if either would work given how the engine works...however $session['styleid'] would probably be cleaner (or maybe even $bbuserinfo['styleid']).

dv6cougar
05-15-2003, 04:59 PM
Today at 06:54 PM filburt1 said this in Post #14 (https://vborg.vbsupport.ru/showthread.php?postid=395488#post395488)
I'm not sure if either would work given how the engine works...however $session['styleid'] would probably be cleaner (or maybe even $bbuserinfo['styleid']).


when i originally wrote up my script above here i did use
$bbuserinfo['styleid'];

but really all you have to do is reset the string to 1 or whatever styleid you wish to use....


i'm gonna take a look at index.php or oen of those files see how it's done, shouldn't be difficult.

thanks again :)

filburt1
05-15-2003, 05:08 PM
Today at 01:59 PM dv6cougar said this in Post #15 (https://vborg.vbsupport.ru/showthread.php?postid=395492#post395492)
when i originally wrote up my script above here i did use
$bbuserinfo['styleid'];

but really all you have to do is reset the string to 1 or whatever styleid you wish to use....


i'm gonna take a look at index.php or oen of those files see how it's done, shouldn't be difficult.

thanks again :)

Try looking specifically at forumdisplay.php because one of the options for a forum is to override the style set :)

dv6cougar
05-15-2003, 05:25 PM
yeah that's what i was thinking ;) good call on that one :)


i'll let you know if i figure this out, it's pretty cool :)

dv6cougar
05-17-2003, 07:48 PM
i'm happy to say that my raffle hack was a 100% success :)

and is now up and running on few beta tests!!!

this was based upon LOGICIAN WEBTEMPLATE & WEBQUERY HACK, a very powerful hack :)

i used his page to show a raffle template and i wrote in all my functions into his php page entitled show.php

i like it :)

not sure if I should actually make an install file and put her up on here, but I'd ask logician first ;)

thanks alot for your help!