/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
/************************************************************************/
/* Additional code clean-up, performance enhancements, and W3C and */
/* XHTML compliance fixes by Raven and Montego. */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
one thing I would think an issue is you are basing your pollid on a random number based on number of rows but the ID's may not match. By this I mean though you may have 10 rows of polls their id's may not number 1 - 10 the could be 1, 6 , 8 14, 16 etc therefore when you looking for pollid 5 it doesn't exist.
You need to change select statement to select id and add to array then select a random array value based on the numrows returned to array.
The issue is it doesnt work It always displays to me the last survey created. Its almost like my efforts to change the pollID is not having any effect.
I dont think its the php rand function. I think Im just not telling it the random number in the right place ??
And Duck points out the potential for a bug perhaps? When the poll id's are no longer sequential.
Joined: Mar 11, 2007 Posts: 1536 Location: North Carolina
Posted:
Sat Mar 14, 2009 1:08 pm
Hers is a random survey block but I get the same thing as you. Only displays last poll not random.
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
$make_random = 1; //0- Means NO random polls. 1- Means random poll.
$number_of_days = 30; //Number of days in between voting per user.
One other issue I noticed would be the fact that you are doing the rand from 0 to -1 from the rows result. The likelyhood of you having a pollid of 0 is not great unless you set one yourself. you should be rand from 1, $total.
Of course this will not cause the failure your getting everytime but just something I noticed in a quick scan of your code.
The code I got comes from chatserv on nukemods in a random survey block he had working there. The block works on ravennuke as well but its not ... well its not "raven nuked" .. and it's not as pretty.
I think on the random function ... the polls start at 0 in the database so poll #1 is really poll 0. So we subtract 1 from the number to be sure Im not asking for poll# 5 when its really 4.
I will try this where pollid = instead of orderby - perhaps thats it.
I was right- I wasent sticking it in the right place.
This one works Thanks guys!
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
/************************************************************************/
/* Additional code clean-up, performance enhancements, and W3C and */
/* XHTML compliance fixes by Raven and Montego. */
/************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header('Location: ../index.php');
die();
}
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum