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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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