Jetzt kostenlos Anmelden!

moon

unregistriert

1

Sonntag, 21. September 2008, 18:11

Umfragen Script

Hallo zusammen,
ich bin ein wenig am verzwifeln, da ich einfach nicht weis was mit diesem Umfragen Script los ist!
Folgendes:
Ich habe die Datei "umfrage.php" in meiner Seite via:

PHP-Quelltext

1
<?php include "umfrage.php";?>
eingefügt.
Nun gibt er mir aus:

Quellcode

1
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\2\umfrage.php on line 12

Die Zeile 12 wäre diese:

PHP-Quelltext

1
         $data mysql_fetch_array($sqlMYSQL_ASSOC);

Was ist damit gemeint?
In der Datei sieht es so aus:

PHP-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
define('GET_CACHES'1);
define('ROOT_PATH''./');
$user_access get_permission();
require(ROOT_PATH.'admin/plugins/umfrage/configs.php');

function ip_exists($table,$id) {
         include "admin/plugins/umfrage/configs.php";
         $sql_conf mysql_query("SELECT * from $configs LIMIT 1");
         $sql_conf mysql_fetch_array($sql_confMYSQL_ASSOC);
         $einheit $sql_conf['sperreinheit'];
         $sperrzeit $sql_conf['sperrdauer'];
         $sekundenanzahl $sperrzeit*$zeiteinheit[$einheit];
         $sql mysql_query("SELECT * from $table WHERE id = '$id' LIMIT 1");
         $data mysql_fetch_array($sqlMYSQL_ASSOC);
         if(ereg($_SERVER['REMOTE_ADDR'], $data['ip']) > 0) {
                  $doit explode("#"$data['ip']);
                  for($x=0;$x<count($doit);$x++) {
                       $findit explode("%"$doit[$x]);
                       if($findit[0]==$_SERVER['REMOTE_ADDR']) {
                          $zeitabstand time()-$findit[1];
                          if($zeitabstand $sekundenanzahl) { return false; break; }
                          else { return true; break; }

                       }
                  }

         }
         else {
            return false;
            }
}
$ant $_POST['ant'];

if(isset($_POST['vote']) && isset($ant) && !ip_exists($umfragen,$_POST['id'])) {
   $id $_POST['id'];
   $sql mysql_query("SELECT * from $umfragen WHERE id = '$id' LIMIT 1");
   $data mysql_fetch_array($sqlMYSQL_ASSOC);
   $votes explode(","$data['votes']);
   $votes[$ant]++;
   $votes implode(","$votes);
   if(!empty($data['ip'])) {
      $ip explode("#"$data['ip']);
      if(ereg($_SERVER['REMOTE_ADDR'], $data['ip']) > 0) {
         for($x=0;$x<count($ip);$x++) {
              $sameip explode("%"$ip[$x]);
              if($sameip[0]==$_SERVER['REMOTE_ADDR']) {
                  $sameip[1]=time();
                  $ip[$x]=implode("%"$sameip);
                  break;
              }
         }
         $ip implode("#"$ip);
      }
      else {
         $result array_push($ip$_SERVER['REMOTE_ADDR']."%".time());
         $ip implode("#"$ip);
      }
   }
   else {
         $ip $_SERVER['REMOTE_ADDR']."%".time();
   }
   $sql mysql_query("UPDATE $umfragen SET votes = '$votes', ip = '$ip' WHERE id = '$id' LIMIT 1");

   /* LOGS ANFERTIGEN START */

   $vote $_POST['ant'];
   $timestamp time();
   $date date("d.m.Y, H:i:s",$timestamp);
   $ip $_SERVER['REMOTE_ADDR'];
   $dns $_SERVER['REMOTE_HOST'];
   $uri $_SERVER['REQUEST_URI'];
   $referrer $_SERVER['HTTP_REFERER'];
   $agent $_SERVER['HTTP_USER_AGENT'];


   /* LOGS ANFERTIGEN END */

   if(!sql) {
      echo "Fehler beim Aktualisieren...";
      mysql_error();
   }


}

         /* Umfragen-Tabelle auslesem*/
         $sql mysql_query("SELECT * FROM $umfragen");
         $counter 0;
         $umfragen mysql_num_rows($sql);
while ($data mysql_fetch_array($sqlMYSQL_ASSOC)) {
 if($data[status] == 1) {
               if($counter>0) echo $abstand;
               /* Frage */
               echo "<form style=\"padding:0px;margin:0px;\" action=\"".$_SERVER['REQUEST_URI'];
               echo "#ergebnisse\" method=\"POST\">\n";
               echo "<div class=\"umfragentext\">";
               echo $data['question'];
               echo "</div>\n";

               /* Antwortmoeglichkeiten */
               $options explode("%%"$data['options']);

         if(!ip_exists($umfragen,$data[id])) {
               echo "<div style=\"padding-left:15px;text-align:left\">";
               for($x=0;$x<count($options);$x++) {
                          echo "<span class=\"umfrageoption\"><input name=\"ant\" value=\"".$x."\" type=\"radio\"> ";
                          echo $options[$x]."</span><br>\n";
               }
               echo "</div>";
               echo "<br><input type=\"hidden\" name=\"id\" value=\"".$data['id']."\">\n";
               echo "<input type=\"submit\" name=\"vote\" value=\"abstimmen\" class=\"vote\"><br>\n";
         }

               if((isset($_POST['results']) && $_POST['id'] == $data['id']) || ip_exists($umfragen,$data[id])) {
                      /* Ergebnisse anzeigen */
                      $voters 0;
                      $max_vote 0;
                      $max_vote_pos 0;
                      $votes explode(","$data['votes']);
                      for($x=0;$x<count($options);$x++) {
                           $voters=$voters+$votes[$x];
                           if($votes[$x] > $max_vote) {
                               $max_vote $votes[$x];
                               $max_vote_pos $x;
                           }
                      }
                      $percentage = array();
                      $hund 0;
                      $pc 0;
                      $end false;
                      while(!$end) {
                            $hund 0;
                            for($x=0;$x<count($options);$x++) {
                                   if($voters==0) {
                                       $percentage[$x] = 0;
                                   }
                                   else {
                                       $percentage[$x]=($votes[$x]*100)/$voters;
                                       $percentage[$x]=round($percentage[$x],$pc);
                                   }
                                       $hund $hund $percentage[$x];
                            }
                            /* Nachkommastellenbestimmung */
                            $pc++;
                            if($hund == 100 || $pc == 2) {
                                   $end true;
                            }
                      }
                      echo "<a id=\"ergebnisse\"></a><div style=\"text-align:left;padding-left:15px;padding-right:11px;padding-top:5px;font-size:11px; font-family:tahoma; color:#222221\">";
                      for($x=0;$x<count($percentage);$x++) {
                           if($max_vote == 0) {
                               $blau 0;
                               $grau $maxlaenge;
                               }
                           else {
                               $blau ceil(($maxlaenge/$max_vote)*$votes[$x]);
                               $grau $maxlaenge $blau;
                               }
                           /*
                           if($blau>$maxlaenge) $blau=$maxlaenge;
                           echo $options[$x]."<br>\n";
                           echo "<img src=\"".$pfad."/balken/balken_";
                           if($blau==$maxlaenge) echo "orange";
                           else echo $farbe;
                           */
                           echo $options[$x]."<br>\n";
                           echo "<img src=\"".$pfad."balken/balken_";
                           echo $farbe;
                           echo ".gif\" height=\"12\" width=\"$blau\" border=\"0\" title=\"$votes[$x] Stimmen\" alt=\"$votes[$x] Stimmen\">";
                           echo "<img src=\"".$pfad."balken/balken_grau.gif\" height=\"12\" width=\"$grau\" border=\"0\" title=\"$votes[$x] Stimmen\" alt=\"$votes[$x] Stimmen\">\n";
                           echo $percentage[$x]."%<br>\n";

                      }
                      echo "</div>";
                      echo "<div class=\"umfragentext\">insgesamt $voters Stimmen</div>\n";
               }
               else {
                     echo "<input type=\"submit\" name=\"results\" value=\"Ergebnisse\" class=\"vote\">\n";
               }

               echo "</form>\n";
               $counter++;
 }
}
if($counter == 0) echo "z.Zt. keine Umfrage aktiv";
?>
  • Zum Seitenanfang
  • Zum Seitenende

Headless Männlich

... nur noch zur deko

Beiträge: 2 374

Geschlecht: Männlich

Wohnort: Nürnberg

PHPKIT Version: keine

2

Montag, 22. September 2008, 14:28

Die Fehlermeldung sagt aus, dass der SQL Abfrage String, bspw:
SELECT * FROM blabla ...
nicht korrekt ist.

Welche Zeilennummer ist das denn? Denn in der Zeile 12 steht laut dem geposten Code von dir etwas ganz anderes.

Gruß
So einfach wie möglich - aber nicht einfacher!
Albert Einstein (1879-1955)
  • Zum Seitenanfang
  • Zum Seitenende

Kobra Männlich

User wurde gesperrt

3

Montag, 22. September 2008, 14:53

Die Zeile 12 dürfte wohl von dieser Datei kommen:

Quellcode

1
require(ROOT_PATH.'admin/plugins/umfrage/configs.php');


mfg
ssssssssssssssssssssssssssssssssssssssssssssss
Es ist, wie es ist 8)
  • Zum Seitenanfang
  • Zum Seitenende