Jump to content

ObscureProtection

New Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by ObscureProtection

  1. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/op/public_html/test.php on line 71

    <?php
    $host = "blahblah.net";
    $data = "thisIsData";
    $user = "PHPhelp";
    $pass = "help";
    $sql = mysql_connect("$host", "$user", "$pass");
    mysql_select_db("$data", $sql);
    
    if(isset($_POST['1']) || isset($_POST['2']) || isset($_POST['3']) || isset($_POST['4']) || isset($_POST['5']))
    {
    if(!empty($_POST['1']))
    	$user_rating = $_POST['1'];
    if(!empty($_POST['2']))
    	$user_rating = $_POST['2']; 
    if(!empty($_POST['3']))
    	$user_rating = $_POST['3']; 
    if(!empty($_POST['4']))
    	$user_rating = $_POST['4']; 
    if(!empty($_POST['5']))
    	$user_rating = $_POST['5'];
    $ip = safeEntry(trim(getenv("REMOTE_ADDR")));
    $date = date('Y-m-d H:i:s');
    $result = mysql_query("select ip from ban where ip='$ip'", $sql);
    Line 71:	$num_rows = mysql_num_rows($result);
    if($num_rows == 0)
    	mysql_query("insert into rate values(null, $entry,'$date', $ip, $user_rating)");
    } ?>
    

  2. I'm getting an: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/op/public_html/test.php on line 70

     

    if(isset($_POST['1']) || isset($_POST['2']) || isset($_POST['3']) || isset($_POST['4']) || isset($_POST['5']))
    {
    if(!empty($_POST['1']))
    	$user_rating = $_POST['1'];
    if(!empty($_POST['2']))
    	$user_rating = $_POST['2']; 
    if(!empty($_POST['3']))
    	$user_rating = $_POST['3']; 
    if(!empty($_POST['4']))
    	$user_rating = $_POST['4']; 
    if(!empty($_POST['5']))
    	$user_rating = $_POST['5'];
    $ip = safeEntry(trim(getenv("REMOTE_ADDR")));
    $date = date('Y-m-d H:i:s');
    Line 70:	if(mysql_num_rows(mysql_query("select ip from ban where ip='$ip'")) == 0)
    	mysql_query("insert into rate values(null, $entry,'$date', $ip, $user_rating)");
    }

     

    I don't understand why it's not working...? It's a code for a voting system (1-5 scale). I'm trying to check to see if the voter IP is banned, if it isn't then insert the voting values.

     

    PHP version 5.2.3

    MySQL version 4.1.22

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.