Poll systeem errors.

Gestart doorJef5 reacties62 weergaven

6 berichten · pagina 1 van 1

Jef

Lid · Topicstarter

Berichten
2.682
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik heb wat errors met mijn poll systeem.
De errors:
Spoiler tonen
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:httphtdocspoll.php on line 4

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:httphtdocspoll.php on line 14

Notice: Undefined variable: me in C:httphtdocspoll.php on line 17

Warning: max(): When only one parameter is given, it must be an array in C:httphtdocspoll.php on line 17

Notice: Undefined variable: poll in C:httphtdocspoll.php on line 19

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:httphtdocspoll.php on line 21

Notice: Undefined variable: poll in C:httphtdocspoll.php on line 83

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:httphtdocspoll.php on line 84
De code:
Spoiler tonen
[COLOR= #0000BB]<?php
    
    $query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `poll` ORDER BY `id` DESC LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$rows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rows[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
        [COLOR= #0000BB]$poll[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$title[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$poll[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$title[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]No Poll Yet[/COLOR][COLOR= #007700];
    }[/COLOR]
    
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(`id`) as hits FROM `responses` GROUP BY `qid`"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
        [COLOR= #0000BB]$me[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]hits[/COLOR][COLOR= #007700]];
    }[/COLOR]
    [COLOR= #0000BB]$max[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/max"]max[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$me[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT `questions`.`pid` FROM  `responses`, `questions` WHERE `responses`.`qid`=`questions`.`id` AND `responses`.`ip`="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" AND pid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$poll[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
    [COLOR= #0000BB]$total[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT `questions`.`pid` FROM  `responses`, `questions` WHERE `responses`.`qid`=`questions`.`id` AND pid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$poll[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$total[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$total[/COLOR][COLOR= #007700]);[/COLOR]
?>
<table width="300" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
    <tr>
        <td valign="top" align="center" class="title">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$title[/COLOR][COLOR= #007700];[/COLOR] ?></td>
    </tr>
    [COLOR= #0000BB]<?php
        $query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `questions` WHERE `pid`="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$poll[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" ORDER BY `question`"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$questions[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$questions[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
    ?>
    <tr>
        <td valign="top" style="padding: 5px;">
        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
            [COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$question[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
                    [COLOR= #0000BB]$responses[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT count(id) as total FROM `responses` WHERE qid="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$question[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                    [COLOR= #0000BB]$responses[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$responses[/COLOR][COLOR= #007700]);[/COLOR]
                    
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$total[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR] [COLOR= #007700]&&[/COLOR] [COLOR= #0000BB]$responses[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]total[/COLOR][COLOR= #007700]] >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
                        [COLOR= #0000BB]$percentage[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/round"]round[/URL][COLOR= #007700](([/COLOR][COLOR= #0000BB]$responses[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]total[/COLOR][COLOR= #007700]][/COLOR] / [COLOR= #0000BB]$max[/COLOR][COLOR= #007700]) *[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700]);
                    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                        [COLOR= #0000BB]$percentage[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];
                    }[/COLOR]
                    
                    [COLOR= #0000BB]$percentage2[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]100[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$percentage[/COLOR][COLOR= #007700];[/COLOR]
            ?>
                <tr>
                    <td valign="top" nowrap="nowrap">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$question[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]question[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
                    <td valign="top" height="10" width="100%" style="padding: 0px 10px;">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td valign="top" width="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$percentage[/COLOR][COLOR= #007700];[/COLOR] ?>%" [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$percentage[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]?>style="background: url(images/bar.jpg) repeat-x;"[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR] ?>><img src="images/dot.gif" width="1" height="19" /></td>
                            <td valign="top" width="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$percentage2[/COLOR][COLOR= #007700];[/COLOR] ?>%"></td>
                        </tr>
                    </table>
                    </td>
                    <td valign="top">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$responses[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]total[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
                </tr>
            [COLOR= #0000BB]<?php[/COLOR]
            [COLOR= #007700]}[/COLOR]
            ?>
            <tr>
                <td valign="top" colspan="3" align="center" style="padding: 10px 0px 0px 0px;">Total Votes: [COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$total[/COLOR][COLOR= #007700];[/COLOR] ?></td>
            </tr>
        </table>
        </td>
    </tr>
    [COLOR= #0000BB]<?php[/COLOR]
        [COLOR= #007700]}[/COLOR]
    ?>
</table>
[COLOR= #0000BB]<?php[/COLOR]
    [COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
?>
<table width="300" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
    <tr>
        <td valign="top" align="center" class="title">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$title[/COLOR][COLOR= #007700];[/COLOR] ?></td>
    </tr>
    [COLOR= #0000BB]<?php
        $query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `questions` WHERE `pid`="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$poll[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" ORDER BY `question`"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$questions[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$questions[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
    ?>
    <tr>
        <td valign="top" style="padding: 5px;">
        <form name="poll" method="post" action="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]];[/COLOR] ?>">
        <table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
        [COLOR= #0000BB]<?php[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$error[/COLOR][COLOR= #007700])){[/COLOR]
        ?>
            <tr>
                <td valign="top" colspan="2" align="center" style="padding: 0px 0px 10px 0px;">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700];[/COLOR] ?></td>
            </tr>
        [COLOR= #0000BB]<?php[/COLOR]
            [COLOR= #007700]}[/COLOR]
        ?>
            [COLOR= #0000BB]<?php[/COLOR]
                [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$question[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])){[/COLOR]
            ?>
                <tr>
                    <td valign="top" style="padding: 0px 10px 0px 0px;"><input type="radio" name="questions" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$question[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR] ?>" /></td>
                    <td valign="top" width="100%">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$question[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]question[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
                </tr>
            [COLOR= #0000BB]<?php[/COLOR]
            [COLOR= #007700]}[/COLOR]
            ?>
            <tr>
                <td valign="top" colspan="2" align="center" style="padding: 10px 0px 0px 0px;"><input type="submit" name="vote" value="Submit Vote" /><br /><a href="http://www.jotlab.com">http://www.jotlab.com</a></td>
            </tr>
        </table>
        </form>
        </td>
    </tr>
    [COLOR= #0000BB]<?php[/COLOR]
        [COLOR= #007700]}[/COLOR]
    ?>
</table>
[COLOR= #0000BB]<?php[/COLOR]
    [COLOR= #007700]}[/COLOR]
?>
<table width="300" cellpadding="0" cellspacing="0" border="0" align="center">
    <tr>
        <td valign="top" align="right"></td>
    </tr>
</table>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Ik zeg: Foutafhandeling op je queries, en isset toevoegen op de lege variabelen.
0
Jef

Lid · Topicstarter

Berichten
2.682
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Ik zeg: Foutafhandeling op je queries, en isset toevoegen op de lege variabelen.
Open source, ik ben slecht met php. emo
0
Jef

Lid · Topicstarter

Berichten
2.682
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Eerdere citaten tonen
Jef schreef:
Eerdere citaten tonen
Aarclay schreef:
Ik zeg: Foutafhandeling op je queries, en isset toevoegen op de lege variabelen.
Open source, ik ben slecht met php. emo
Alles valt te leren:
- Foutafhandeling: http://www.phphulp.nl/php/tutorial/data-verwerking/foutafhandeling-query-sql/735/
- Isset: php.net/isset
Ik snap er nog steeds geen fuck van. emo
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Tja, dan moet je lezen en proberen hé sadley
(waar is de ik probeer eens wat-mentaliteit tegenwoordig shutup)
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren