MySQL warning error! Help me!

Discussion in 'PHP' started by AleckProg, Apr 26, 2007.

  1. #1
    I hve doing a poll script in PHP and all is working perfectly, but only it has this error when I sent my vote, and do not know how to solve:

    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/u7/web/html/index/encuesta.php on line 9

    PHPCode is:

    
    include('db.php');
    $opciones = array ('DJ-ERR0R-','DJ-Ray','DJ-AdituS','DJ-Lydi','DJ-L3y');
    if(isset($_GET["voto"])){
       $ip = $REMOTE_ADDR;
       $sql ="INSERT INTO encuesta (ip,voto) VALUES ('$ip',".$_GET["voto"].")";
    LINE OF ERROR->   $votos = mysql_result(mysql_query($sql),0);  
    }
    $i = 0;
    $sql ="SELECT count(ip) FROM encuesta";
    $total = mysql_result(mysql_query($sql),0); 
    echo "<form><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
    while ($opciones[$i]){
       $sql ="SELECT count(ip) FROM encuesta WHERE voto = $i";
       $votos = mysql_result(mysql_query($sql),0);
       @$porcentaje = round($votos/$total*100,2);
       echo "  <tr>\n";
       echo "    <td colspan=\"3\"><b>$opciones[$i]</b></td>\n";
       echo "  </tr>\n";
       echo "  <tr>\n";
       echo "    <td><input type=\"radio\" value=\"$i\" name=\"voto\"></td>\n";
       echo "    <td><hr color=\"blue\" size=\"10\" width=\"$porcentaje\" align=\"left\">\n";
       echo "    </td>\n";
       echo "    <td align=\"right\">$porcentaje% ($votos)</td>\n";
       echo "  </tr>\n";
       $i++;
    }
    echo "  <tr>\n";
    echo "    <td colspan=\"3\"><br><input type=\"submit\" value=\"Votar\"></td>\n";
    echo "  </tr>\n";
    echo "</table></form>";
    
    
    PHP:
     
    AleckProg, Apr 26, 2007 IP
  2. Adam A Flynn

    Adam A Flynn Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That error message means that you aren't properly connected to MySQL. Your real issue is with mysql_connect in db.php.
     
    Adam A Flynn, Apr 26, 2007 IP
  3. AleckProg

    AleckProg Guest

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No, it's not the problem! Please somebody that may help me!
     
    AleckProg, Apr 26, 2007 IP
  4. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Thats some confusing PHP coding right there. What exactly are you trying to do?
     
    Arson, Apr 26, 2007 IP
  5. AleckProg

    AleckProg Guest

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I did that script and is working correctly, but when somebody send vote, it get mysql error on line 9. Get up and read my first post of this thread.
     
    AleckProg, Apr 26, 2007 IP
  6. AleckProg

    AleckProg Guest

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If somebody can leave good help, please do it.
     
    AleckProg, Apr 26, 2007 IP