Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    ...nothing happens... at all

    I just converted this simple poll script from text file to mSQL database driven so I've probably bodged it up somewhere but nothing happens, at all, no errors, just nothing, the source code is empty... even if the variables were all empty at least the basic HTML should be there...
    I'm stumped, error messages I can fix - but I'm getting nothing.

    PHP Code:
    <?php
    session_start
    ();
    include(
    'db.php');
    $strSQL "SELECT * FROM Questions WHERE Active = 1";
    $question mysql_fetch_array(mysql_query($strSQL)) or die(mysql_error());
    //register vote.
    $strSQL "SELECT * FROM Poll WHERE QuestionID = ".$question['ID'];
    $result=mysql_query($strSQL)or die(mysql_error());

    $j=0;
    $x=1;
    $num_fields mysql_num_fields($result); 
    while(
    $row=mysql_fetch_array($strSQL)){ 
      for(
    $j=0;$j<$num_fields;$j++){
       
    $name mysql_field_name($result$j);
       
    $answers[$x][$name]=$row[$name];
      }
    $x++;
    }

    $vote $_GET['PollVote'];
    $filestring "";
    $totalvotes 0;

    if(empty(
    $_SESSION['voted']))
    {
    $answers[$vote]['Votes'] = $answers[$vote]['Votes']+1;
    foreach(
    $answers[]['Votes'] as $result){
    $totalvotes =$totalvotes +$result;
    }
    $strSQL "UPDATE Poll SET Votes = Votes+1 WHERE ID = ".$answers[0]['ID']+$vote;

    $_SESSION['voted'] = true;
    $_SESSION['votes'] = $totalvotes;
    }


    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Poll Results</title>
    <link href="css/common.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <div style = "border:1px solid #53217E; padding-bottom:5px;">
    <img src="images/smallbanner.gif" />
    <table align = "center" bgcolor="#8F74AB"  width = "288" style="color:#FFFFFF; font-weight:bold;" >
    <?php 
    echo "<tr><td colspan = \"3\">$question</td></tr>";
    $totalvotes $_SESSION['votes'];
    for(
    $i 0$i<count($answers); $i++)
    {
    $percent intval(($answers[$i]['Votes']/$totalvotes)*100);
    $width $percent;
    $result trim($results[$i],"\n");
    echo 
    "<tr height =\"20\" valign = \"middle\"><td>$answers[$i]['Answer']</td><td width = \"110\"> <img src = \"images/poll.gif\" width = \"$width\" height = \"10\" style =\"border:1px solid #4B256C\" /></td><td>$percent%</td></tr>\n";
    }
    echo 
    "<tr><td></td><td></td><td>$totalvotes votes</td></tr>";
    ?>

    </table>
    </div>
    </body>
    </html>

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    Ignore me, I'm being an idiot...

    anyone else in the UK cant think in this heat?!

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nup, t'is awful. I wouldn't mind the heat if I was on the beach but it's no fun in the office


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •