X-Poll Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

X-Poll Help

Post by nickman013 »

Hello.

I am running x-poll on my website.

It works good but I get one problem.

When I try to include the poll into a page, I have to include two things.

top.php and polls.php

top.php is

Code: Select all

<?php

include ("config.php");

if (isset ($_REQUEST['poll'])) {

	$result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' AND pollid='$_REQUEST[poll]'");
	
} else {

	$result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' ORDER BY pollid DESC LIMIT 1");
	
}

$totalpolls = mysql_num_rows ($result);

if ($totalpolls > 0) {

	$polls = mysql_fetch_array ($result);
	
	$whatpoll = $polls['pollid'];
	$title = $polls['title'];
	
	// Calculate Poll Expiration
	list ($dayx, $monthx, $yearx) = explode ("/", $polls['expires']);
	$now = mktime (0, 0, 0, date ("m"), date ("d"), date ("Y"));
	$expire = mktime (0, 0, 0, $monthx, $dayx, $yearx);
	
	if ($expire <= $now) {
	
		$expired = "yes";
		
	} else {
	
		$expired = "no";
		
	}
	
	// Calculate Poll Start
	if ($expired == "no") {
	
		list ($days, $months, $years) = explode ("/", $polls['starts']);
		$starts = mktime (0, 0, 0, $months, $days, $years);
	
		if ($starts > $now) {
	
			$started = "no";
		
		} else {
	
			$started = "yes";
		
		}
		
	} else {
	
		$started = "no";
	
	}
	
	// Check if IP is blocked from voting
	$blockcheck = mysql_num_rows (mysql_query ("SELECT blockedid FROM blocked WHERE (polls LIKE '%$polls[title]%' OR polls LIKE '%all%') AND ip='$_SERVER[REMOTE_ADDR]'"));
	
	if ($blockcheck == 0) {
	
		$blocked = "no";
		
	} else {
	
		$blocked = "yes";
		
	}
	
	// Check if user has voted (IP)
	if ($polls['ip'] == "yes") {
	
		$check = mysql_query ("SELECT ipid, vote FROM ip WHERE title='$polls[title]' AND ip='$_SERVER[REMOTE_ADDR]'");
		$checkip = mysql_num_rows ($check);
		$ip = mysql_fetch_array ($check);
		
		if ($checkip == 0 | $ip['vote'] < time ()) {
		
			$voteip = "yes";
			
		} else {
		
			$voteip = "no";
			
		}
		
		if ($ip['vote'] <= time ()) {
		
			mysql_query ("DELETE FROM ip WHERE title='$polls[title]' AND ip='$_SERVER[REMOTE_ADDR]'");
			
		}
		
	} else {
	
		$voteip = "none";
		
	}
	
	// Check if user has voted (Cookie)
	if ($polls['cookies'] == "yes") {
		
		if (isset ($_COOKIE[$whatpoll])) {
		
			if ($_COOKIE[$whatpoll] == $title) {
		
				$votecookies = "no";
				
			} else {
			
				$votecookies = "yes";
			
			}
			
		} else {
		
			$votecookies = "yes";
			
		}
		
	} else {
	
		$votecookies = "none";
		
	} 
	
	if (isset ($_POST['stage'])) {

		$polls = mysql_fetch_array (mysql_query ("SELECT title, vote, ip, cookies FROM polls WHERE status='on' AND pollid='$_POST[poll]'"));
		$options = mysql_fetch_array (mysql_query ("SELECT optionid, options, votes FROM options WHERE pollid='$_POST[poll]' AND optionid='$_POST[option]'"));
		
		$title = $polls['title'];
		
		$nextvote = $polls['vote'] + time ();
		$votes = $options['votes'] + 1;
		
		if ($polls['ip'] == "yes" && $voteip != 'no') {
		
			$ip = mysql_fetch_array (mysql_query ("SELECT ipid FROM ip ORDER BY ipid DESC"));
			
			$ipid = $ip['ipid'] + 1;
		
			mysql_query ("INSERT INTO ip (ipid, title, ip, vote) VALUES ('$ipid', '$polls[title]', '$_SERVER[REMOTE_ADDR]', '$nextvote')");
			
		}
		
		if ($polls['cookies'] == "yes" && $votecookies != 'no') {
		
			setcookie ($whatpoll, $title, $nextvote);
			
		}
		
		if ($votecookies != 'no' && $voteip != 'no' && $blocked != 'yes' && $started == 'yes' && $expired == 'no') {
		
			mysql_query ("UPDATE options SET votes='$votes' WHERE optionid='$options[optionid]'");
			
		}
				
	}
	
}
	
?>
and polls.php is

Code: Select all

<?php

if ($totalpolls > 0) {

	if (!isset ($_REQUEST['option']) && !isset ($_REQUEST['results']) && $votecookies != 'no' && $voteip != 'no' && $blocked != 'yes' && $started == 'yes' && $expired == 'no' && $polls['voting'] == 'yes') {
	
		$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph FROM polls WHERE pollid='$whatpoll'"));

		$option = mysql_query ("SELECT optionid, options, order_id FROM options WHERE pollid='$whatpoll' ORDER BY order_id ASC");
	
?>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post" name="frmPoll">
<table width="22%" border="0" cellspacing="0" cellpadding="2" class="border">
	<tr bgcolor="#0099FF" class="text">
		<td height="25" colspan="2" align="center"><b><?= $poll['title']; ?></b></td>
	</tr>
	<?php while ($optionrows = mysql_fetch_array ($option)) { ?>
	<tr class="text">
		<td width="10%" align="center" height="25"><input name="option" type="radio" value="<?= $optionrows['optionid']; ?>"<?php if ($optionrows['order_id'] == 1) { echo " CHECKED"; } ?>></td>
		<td width="90%"><?= $optionrows['options']; ?></td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="2" align="center" height="25"><input name="stage" type="hidden" value="2"><input name="poll" type="hidden" value="<?= $poll['pollid']; ?>"><input name="btnVote" type="submit" value="Vote" class="text">
		<?php if ($poll['results'] == 'yes' && $poll['graph'] == 'yes') { ?><br><a href="<?= $_SERVER['PHP_SELF']; ?>?poll=<?= $whatpoll; ?>&results=1" class="text">View Results</a><?php } ?></td>
	</tr>
</table>
</form>
<?php
	
	}

	$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='$whatpoll'"));
		
		if (($blocked == 'yes' | $voteip == 'no' | $votecookies == 'no' | isset ($_REQUEST['results']) | $poll['voting'] == 'no' | isset ($_REQUEST['option'])) && $poll['graph'] == 'yes' && $started == 'yes') {
		
			if (((isset ($_REQUEST['results']) && $poll['results'] == 'yes' && ($voteip != 'yes' | $votecookies != 'yes')) | !isset ($_REQUEST['results'])) && $started == 'yes') {
			
				$option = mysql_query ("SELECT options, votes, images, order_id FROM options WHERE pollid='$whatpoll' ORDER BY order_id ASC");
				$total = mysql_fetch_assoc (mysql_query ("SELECT SUM(votes) AS total FROM options WHERE pollid='$whatpoll'"));

?>
<link href="css/css.css" rel="stylesheet" type="text/css">
<table width="22%" border="0" cellspacing="0" cellpadding="2" class="border">
	<tr class="text">
		<td height="25" colspan="2" align="center" bgcolor="#0099FF"><b><?= $poll['title']; ?></b></td>
	</tr>
	<?php 
	
	while ($optionrows = mysql_fetch_array ($option)) {
	
		@$percent = round (($optionrows['votes'] / $total['total']) * 100);
	
		if ($optionrows['images'] == 'random') {
					
			if ($handle = opendir ($dir2)) {
				  
				while (false !== ($file = readdir ($handle))) {
														
					if ($file != '.' && $file != '..') {
									
						$files[] = $file;
									
					}				
									
				}
								
				shuffle ($files);
							
			}
							
			$rand = rand (0, (count ($files) - 1));
							
			$optionrows['images'] = $files[$rand];
							
		}
	
?>
	<tr class="text">
		<td width="10%" height="25"><?= $optionrows['options']; ?> - <b><?= $percent; ?>%</b><?php if ($poll['resultsvotes'] == "yes") { echo " / ".$optionrows['votes']." Votes"; } ?></td>
	</tr>
	<tr class="text">
		<td width="10%" height="25"><img src="<?= $dir2; ?>/<?= $optionrows['images']; ?>" width="<?= ($percent * $width) + 10; ?>" height="<?= $height; ?>" alt="<?= $optionrows['options']; ?>"></td>
	</tr>
	<?php } ?>
	<tr class="text">
		<td height="25" align="center"><?php if ($poll['resultsvotes'] == "yes") { ?><b>Total Votes: <?= $total['total']; ?></b><?php } if (isset ($_REQUEST['results'])) {?><br><a href="<?= $_SERVER['PHP_SELF']; ?>?poll=<?= $whatpoll; ?>" class="text">Vote On Poll</a><?php } ?></td>
	</tr>
</table>
<?php

		}

	}

} else {

?>
<div align="center" class="text"><b>Error:</b> There are currently no polls. Please <a href="admin/index.php" class="text">create</a> one.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'no' && $poll['graph'] == 'no') { ?>
<div align="center" class="text">Sorry you cannot vote or view results on this poll.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'yes' && $poll['graph'] == 'no' && isset ($_REQUEST['option'])) { ?>
<div align="center" class="text">Thanks for voting on the poll.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'yes' && $poll['graph'] == 'no' && ($voteip == 'no' | $votecookies == 'no') && !isset ($_REQUEST['option'])) { ?>
<div align="center" class="text">Sorry, you cannot view the results for poll <b><?= $polls['title']; ?></b></div>
<?php } if ($totalpolls > 0 && $poll['results'] == 'no' && isset ($_REQUEST['results'])) { ?>
<div align="center" class="text">Sorry, you cannot view the results for poll <b><?= $polls['title']; ?></b></div>
<?php } ?>
The problem I am getting while including them into a page, is this.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/muot/public_html/xpoll/polls.php on line 7

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/muot/public_html/xpoll/polls.php on line 17


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/muot/public_html/xpoll/polls.php on line 33
Line 7
$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph FROM polls WHERE pollid='$whatpoll'"));
Line 17
<?php while ($optionrows = mysql_fetch_array ($option)) { ?>
Line 33
$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='$whatpoll'"));
If anybody knows how to fix this, please tell me . I really would like to use this script.

THANK YOU!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Test your queries to see if they are working. That is probably your problem. I'm not sure that variables in 'single' qoutes get converted either.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Thanks for the suggestion.

I ran lines 7 and 33, I dont know how to run 17 in phpMyAdmin.
I need help concating a variables into the query. I thought I did it correct but I was still getting the error.

I tried concating line 7 like this.

Code: Select all

poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph FROM polls WHERE pollid=".$whatpoll)
);
and line 33 like this

Code: Select all

mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid=".$whatpoll);
Any help would be great. Thanks alot.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

separate your statements out, for two reasons

1) debugging
2) checking if results are returned before storing into an array

Code: Select all

$sql = "SELECT my QUERY text";  // pretty clever huh? ;d

// debug
echo $sql;

$result = mysql_query($sql) or die(mysql_error());  // was there an error returned?

// check for result
if($array = mysql_fetch_array($result)){   // this will evaluate to true or false
   echo "Results were returned and stored in an array";
} ELSE {
   echo "No results were returned.";
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

helps code readability too.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Ok, thanks for the reply's!

$sql = "SELECT pollid, title, voting, results, graph FROM polls WHERE pollid='$whatpoll'";

Returned
SELECT pollid, title, voting, results, graph FROM polls WHERE pollid=1 Results were returned and stored in an array
------------------------

$sql = "SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='$whatpoll'";

Returned
SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='1'Results were returned and stored in an array
-----------------------


I do not know how to put the other one into the code you provided me.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

on every instance of mysql_query() .. change it to

Code: Select all

mysql_query() or die(mysql_error());
for a more helpful error message (as mentioned previously)
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Now I get this
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/muot/public_html/xpoll/polls.php on line 7
Table 'muot_tracker.options' doesn't exist
I dont know where it is adding .options to the table name. The DB is muot_tracker, and options is the table.

polls.php as of now

Code: Select all

<?php

if ($totalpolls > 0) {

	if (!isset ($_REQUEST['option']) && !isset ($_REQUEST['results']) && $votecookies != 'no' && $voteip != 'no' && $blocked != 'yes' && $started == 'yes' && $expired == 'no' && $polls['voting'] == 'yes') {
	
		$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph FROM polls WHERE pollid=".$whatpoll));

		$option = mysql_query ("SELECT optionid, options, order_id FROM options WHERE pollid='$whatpoll' ORDER BY order_id ASC") or die(mysql_error());
	
?>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post" name="frmPoll">
<table width="22%" border="0" cellspacing="0" cellpadding="2" class="border">
	<tr bgcolor="#0099FF" class="text">
		<td height="25" colspan="2" align="center"><b><?= $poll['title']; ?></b></td>
	</tr>
	<?php while ($optionrows = mysql_fetch_array ($option)) { ?>
	<tr class="text">
		<td width="10%" align="center" height="25"><input name="option" type="radio" value="<?= $optionrows['optionid']; ?>"<?php if ($optionrows['order_id'] == 1) { echo " CHECKED"; } ?>></td>
		<td width="90%"><?= $optionrows['options']; ?></td>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="2" align="center" height="25"><input name="stage" type="hidden" value="2"><input name="poll" type="hidden" value="<?= $poll['pollid']; ?>"><input name="btnVote" type="submit" value="Vote" class="text">
		<?php if ($poll['results'] == 'yes' && $poll['graph'] == 'yes') { ?><br><a href="<?= $_SERVER['PHP_SELF']; ?>?poll=<?= $whatpoll; ?>&results=1" class="text">View Results</a><?php } ?></td>
	</tr>
</table>
</form>
<?php
	
	}

	$poll = mysql_fetch_array (mysql_query ("SELECT pollid, title, voting, results, graph, resultsvotes FROM polls WHERE pollid='$whatpoll'"))or die(mysql_error());
		
		if (($blocked == 'yes' | $voteip == 'no' | $votecookies == 'no' | isset ($_REQUEST['results']) | $poll['voting'] == 'no' | isset ($_REQUEST['option'])) && $poll['graph'] == 'yes' && $started == 'yes') {
		
			if (((isset ($_REQUEST['results']) && $poll['results'] == 'yes' && ($voteip != 'yes' | $votecookies != 'yes')) | !isset ($_REQUEST['results'])) && $started == 'yes') {
			
				$option = mysql_query ("SELECT options, votes, images, order_id FROM options WHERE pollid='$whatpoll' ORDER BY order_id ASC");
				$total = mysql_fetch_assoc (mysql_query ("SELECT SUM(votes) AS total FROM options WHERE pollid='$whatpoll'"));

?>
<link href="css/css.css" rel="stylesheet" type="text/css">
<table width="22%" border="0" cellspacing="0" cellpadding="2" class="border">
	<tr class="text">
		<td height="25" colspan="2" align="center" bgcolor="#0099FF"><b><?= $poll['title']; ?></b></td>
	</tr>
	<?php 
	
	while ($optionrows = mysql_fetch_array ($option)) {
	
		@$percent = round (($optionrows['votes'] / $total['total']) * 100);
	
		if ($optionrows['images'] == 'random') {
					
			if ($handle = opendir ($dir2)) {
				  
				while (false !== ($file = readdir ($handle))) {
														
					if ($file != '.' && $file != '..') {
									
						$files[] = $file;
									
					}				
									
				}
								
				shuffle ($files);
							
			}
							
			$rand = rand (0, (count ($files) - 1));
							
			$optionrows['images'] = $files[$rand];
							
		}
	
?>
	<tr class="text">
		<td width="10%" height="25"><?= $optionrows['options']; ?> - <b><?= $percent; ?>%</b><?php if ($poll['resultsvotes'] == "yes") { echo " / ".$optionrows['votes']." Votes"; } ?></td>
	</tr>
	<tr class="text">
		<td width="10%" height="25"><img src="<?= $dir2; ?>/<?= $optionrows['images']; ?>" width="<?= ($percent * $width) + 10; ?>" height="<?= $height; ?>" alt="<?= $optionrows['options']; ?>"></td>
	</tr>
	<?php } ?>
	<tr class="text">
		<td height="25" align="center"><?php if ($poll['resultsvotes'] == "yes") { ?><b>Total Votes: <?= $total['total']; ?></b><?php } if (isset ($_REQUEST['results'])) {?><br><a href="<?= $_SERVER['PHP_SELF']; ?>?poll=<?= $whatpoll; ?>" class="text">Vote On Poll</a><?php } ?></td>
	</tr>
</table>
<?php

		}

	}

} else {

?>
<div align="center" class="text"><b>Error:</b> There are currently no polls. Please <a href="admin/index.php" class="text">create</a> one.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'no' && $poll['graph'] == 'no') { ?>
<div align="center" class="text">Sorry you cannot vote or view results on this poll.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'yes' && $poll['graph'] == 'no' && isset ($_REQUEST['option'])) { ?>
<div align="center" class="text">Thanks for voting on the poll.</div>
<?php } if ($totalpolls > 0 && $poll['voting'] == 'yes' && $poll['graph'] == 'no' && ($voteip == 'no' | $votecookies == 'no') && !isset ($_REQUEST['option'])) { ?>
<div align="center" class="text">Sorry, you cannot view the results for poll <b><?= $polls['title']; ?></b></div>
<?php } if ($totalpolls > 0 && $poll['results'] == 'no' && isset ($_REQUEST['results'])) { ?>
<div align="center" class="text">Sorry, you cannot view the results for poll <b><?= $polls['title']; ?></b></div>
<?php } ?>
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I have tried reinstalling the script on my site, but same error. No body has posted any comments about this issue on the HotScripts site. Does anybody else know of a good and simple poll script like this, One that may include comments too?
User avatar
Fractal
Forum Commoner
Posts: 54
Joined: Tue Aug 16, 2005 1:28 pm

Post by Fractal »

Where is $whatpoll defined in your code?

EDIT: I see, it's a cookie setting in top.php, I'll look it over again .-.

EDIT2:

Code: Select all

<?php

if ($totalpolls > "0") {
  if (!isset($_REQUEST['option']) && !isset($_REQUEST['results']) && $votecookies != "no" && $voteip != "no" && $blocked != "yes" && $started == "yes" && $expired == "no" && $polls['voting'] == "yes") {
    $poll = mysql_fetch_array(mysql_query("SELECT pollid,title,voting,results,graph FROM polls WHERE pollid='".$whatpoll."'"));
    $option = mysql_query("SELECT optionid, options, order_id FROM options WHERE pollid='".$whatpoll."' ORDER BY order_id ASC") or die(mysql_error());
    echo "
<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" name=\"frmPoll\">
<table width=\"22%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"border\">
    <tr bgcolor=\"#0099FF\" class=\"text\">
        <td height=\"25\" colspan=\"2\" align=\"center\"><b>".$poll['title']."</b></td>
    </tr>";
    while($optionrows = mysql_fetch_array($option)) {
      echo "
      <tr class=\"text\">
        <td width=\"10%\" align=\"center\" height=\"25\"><input type=\"option\" type=\"radio\" value=\"".$optionrows['optionid']."\">";
        if ($optionrows['order_id'] == "1") echo " CHECKED></td>
      </tr>
</table>
</form>";
    }
    $poll = mysql_fetch_array(mysql_query("SELECT * pollid,title,voting,results,graph,resultsvotes FROM polls WHERE pollid='".$whatpoll."'")) or die(mysql_error());
    if (($blocked == "yes" || $voteip == "no" || $votecookies == "no" || isset($_REQUEST['results']) || $poll['voting'] == "no" || isset($_REQUEST['option'])) && $poll['graph'] == "yes" && $started == "yes") {
      if (((isset($_REQUEST['results']) && $poll['results'] == "yes" && ($voteip != "yes" || $votecookies != "yes")) || !isset($_REQUEST['results']) && $started == "yes")) {
        $option = mysql_query("SELECT options,votes,images,order_id FROM options WHERE pollid='".$whatpoll."' ORDER BY order_id ASC");
        $total = mysql_fetch_assoc(mysql_query("SELECT SUM(votes) AS total FROM options WHERE pollid='".$whatpoll."'"));
        echo "<link href=\"css/css.php\" rel=\"stylesheet\" type=\"text/css\">
<table width=\"22%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">
    <tr class=\"text\">
        <td height=\"25\" colspan=\"2\" align=\"center\" bgcolor=\"#0099FF\"><b>".$poll['title']."</b></td>
    </tr>";
        while ($optionrows = mysql_fetch_array($option)) {
          @$percent = round(($optionrows['votes'] / $total['total']) * 100);
          if ($optionrows['images'] == "random") {
            if ($handle = opendir($dir2)) {
              while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..\"") {
                  $files[] = $file;
                }
              }
              shuffle($files);
            }
            $rand = rand(0,(count($files) - 1));
            $optionrows['images'] = $files[$rand];
          }
          echo "
     <tr class=\"text\">
         <td width=\"10%\" height=\"25\">".$optionrows['options']." - <b>".$percent."%</b>";
         if ($poll['resultsvotes'] == "yes") echo " / ".$optionrows['votes']." Votes</td>
     </tr>
     <tr class=\"text\">";
         $dir2 = $dir2."/";
         echo "
         <td width=\"10%\" height=\"25\"><img src=\"".$dir2.$optionrows['images']."\" width=\"".(($percent * $width) + 10)."\" height=\"".$height."\" alt=\"".$optionrows['options']."\"></td>
     </tr>";
        }
        echo "
     <tr class=\"text\">
       <td height=\"25\" align=\"center\">";
        if ($poll['resultsvotes'] == "yes") { echo "<b>Total Votes: ".$total['total']."</b>"; } if (isset($_REQUEST['results'])) { echo "<br /><a href=\"".$_SERVER['PHP_SELF']."?poll=".$whatpoll."\" class=\"text\">Vote On Poll</a>"; } echo "</td>
     </tr>
</table>";
      }
    }
  } else {
    echo "<div align=\"center\" class=\"text\"><b>Error:</b> There are currently no polls. Please <a href=\"admin/index.php\" class=\"text\">create</a> one.</div>";
  }
}
if ($totalpolls > "0" && $pollvoting == "no" && $poll['graph'] == "no") { echo "\n<div align=\"center\" class=\"text\">Sorry you cannot vote or view results on this poll.</div>"; }
if ($totalpolls > "0" && $pollvoting == "yes" && $poll['graph'] == "no" && isset($_REQUEST['option'])) { echo "\n<div align=\"center\" class=\"text\">Thanks for voting on the poll.</div>"; }
if ($totalpolls > "0" && $pollvoting == "yes" && $poll['graph'] == "no" && ($voteip == "no" || $votecookies == "no") && !isset($_REQUEST['option'])) { echo "\n<div align=\"center\" class=\"text\">Sorry, you cannot view the results for poll <b>".$polls['title']."</b>.</div>"; }
if ($totalpolls > "0" && $pollvoting == "no" && $poll['graph'] == "no" && isset($_REQUEST['results'])) { echo "\n<div align=\"center\" class=\"text\">Sorry you cannot view results on poll <b>".$polls['title']."</b>.</div>"; }

?>
Well, I'm not sure what fixed it but I tried to keep it exactly like yours, and I tested it so it does work (Didn't test the queries though, I don't think they'll parse though).
Post Reply