Jump to content

[SOLVED] hmmm...wonder where i went wrong


HoTDaWg

Recommended Posts

Try:
[code]<?php
    error_reporting(E_ALL);
    define('inStereo',true);
    $ip = $_SERVER["REMOTE_ADDR"];
    echo $ip;
    include "config.php";

    $limit = 3;

function beginthework(){
global $ip, $limit;
    $sql = "SELECT * FROM users WHERE ip='$ip'";
    if ($result = mysql_query($sql)) {
        if (mysql_num_rows($result) > 0) {
            $row = mysql_fetch_assoc($result);
            if ($row['voted'] > $limit) {
                echo "Our records show that you have already voted three times. As much as we hate to say it, access denied.";
            } elseif ($row['voted'] == 0) {
                define('firsttime',true);
                echo 'this is your first time voting.<form name="request" action="request.php">
                Artist Name:<input type="text" name="artist">song name:<input type="text" name="song"><br><br>
                <input type="submit" value="Submit!"></form>';
            } else {
                define('morethanonce',true);
                echo 'You have voted before.<form name="request" action="request.php">
                Artist Name:<input type="text" name="artist">song name:<input type="text" name="song"><br><br>
                <br><br><input type="submit" value="Submit!"></form>';
            } 
        }  else { echo "no results for this IP"; }
    }  else { echo "problem with database"; }
}

beginthework();
?>[/code]
alright i changed the code a bit. The only problem is it still does absouletly nothing! ???
1. i changed it so that in select the (dollar sign)ip variable inside the select comand would not have quotes, cuz in  a previous topic i made the reason that php didnt read my script was because it doesnt read variables inside of quotes. so here is the sccript:
[code]
<?php
    error_reporting(E_ALL);
    define('inStereo',true);
    $ip = $_SERVER["REMOTE_ADDR"];
    echo $ip;
    include "config.php";

    $limit = 3;

function beginthework(){
global $ip, $limit;
    $sql = "SELECT * FROM users WHERE ip=$ip";
    if ($result = mysql_query($sql)) {
        if (mysql_num_rows($result) > 0) {
            $row = mysql_fetch_assoc($result);
            if ($row['voted'] > $limit) {
                echo "Our records show that you have already voted three times. As much as we hate to say it, access denied.";
            } elseif ($row['voted'] == 0) {
                define('firsttime',true);
                echo 'this is your first time voting.<form name="request" action="request.php">
                Artist Name:<input type="text" name="artist">song name:<input type="text" name="song"><br><br>
                <input type="submit" value="Submit!"></form>';
            } elseif ($row['ip'] == ""){
                define('morethanonce',true);
                echo 'You have voted before.<form name="request" action="request.php">
                Artist Name:<input type="text" name="artist">song name:<input type="text" name="song"><br><br>
                <br><br><input type="submit" value="Submit!"></form>';
            } 
      }
    }  else { echo "problem with database"; }
}

beginthework();
?>
[/code]
I take that as it doesnt. The problem is, there arent any IPs (that match) in the DB.

Try:
[code]<?php
  error_reporting(E_ALL);
  define('inStereo',true);
  $ip = $_SERVER["REMOTE_ADDR"];
  echo $ip;
  include "config.php";

  $limit = 3;

  function beginthework(){
    global $ip, $limit;
    $sql = "SELECT * FROM users WHERE ip=$ip";
    if ($result = mysql_query($sql)) {
      if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_assoc($result);
        if ($row['voted'] > $limit) {
          echo "Our records show that you have already voted three times. As much as we hate to say it, access denied.";
        } else {
          define('morethanonce',true);
          echo 'You have voted before.<form name="request" action="request.php">
          Artist Name:<input type="text" name="artist">song name:<input type="text" name="song"><br><br>
          <br><br><input type="submit" value="Submit!"></form>';
        }
      }
    }  else { define('firsttime',true);
      echo 'this is your first time voting.<form name="request" action="request.php">
      Artist Name:<input type="text" name="artist">song name:<input type="text" name="song"><br><br>
      <input type="submit" value="Submit!"></form>';
    }
  }

  beginthework();
?>[/code]

That should work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.