Author Topic: Script Probleme  (Read 4353 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Script Probleme
« on: September 21, 2008, 06:13:45 PM »
Hallo zusammen,

ich habe eine Script, welches im root liegt!
Ich rufe es in der home.html so auf:
Code: [Select]
<?php include "umfrage.php";?>
Nun gibt er mir aber folgendes aus:
Code: [Select]
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:
Code: [Select]
         $data = mysql_fetch_array($sql, MYSQL_ASSOC);
In der Datei sieht es so aus:
Code: [Select]
<?php
require "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";
?>

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Script Probleme
« Reply #1 on: September 21, 2008, 06:49:49 PM »
lieber phisker,

dies hat NICHTS mit der ORIGINAL 4images version zutun..
wie oft noch? ;)
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.423
    • View Profile
    • 4images - Image Gallery Management System
Re: Script Probleme
« Reply #2 on: September 21, 2008, 07:04:26 PM »
Moved to Chit Chat.
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Script Probleme
« Reply #3 on: September 21, 2008, 08:51:21 PM »
Ach menno, tut mir sorry ;)

Ich vergesse immer das wir ja hier nen Chit Chat haben :D