SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 55
  1. #26
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since each IP can vote multiple times, just not for the same ID, you would have to alter that query to be something like...

    Code:
    SELECT * FROM clicks where ip=$ip and id=$id
    Which, by the way, is probably a much better way of doing this.

  2. #27
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Good point, missed that bit out of the code, it was in the original...
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #28
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ill try this now.... thanks guys... ill post if it solves it
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  4. #29
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Viflux - "Could not add click." no matter what!
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  5. #30
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you cleared out your database?

  6. #31
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  7. #32
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, try running this exact code...

    PHP Code:
    <?php

    include_once( 'config.php' );

    $ip $_SERVER'REMOTE_ADDR' ]; 
    $id $_GET'id' ];

    echo 
    $ip '<br>';
    echo 
    $id '<br>';

    $query 'SELECT * FROM clicks WHERE id=' $id ' AND ip="' $ip '"';
    echo 
    $query '<br>';

    $result mysql_query$query ) or die( 'ERROR!' );

    echo 
    mysql_num_rows$result ) . '<br>';

    ?>

  8. #33
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    81.218.107.147
    1
    SELECT * FROM clicks WHERE id=1 AND ip="81.218.107.147"
    0
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  9. #34
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    did you try my code?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  10. #35
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ts not what i need.... i want the same ip able to vote twice, but not same id..
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  11. #36
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php 

    include( 'config.php' ); 

    $ip $_SERVER'REMOTE_ADDR' ]; 
    $id $_GET'id' ]; 

    $query 'SELECT * FROM clicks WHERE id=' $id ' AND ip="' $ip '"'
    $result mysql_query$query ) or die( 'ERROR!' ); 

    if( 
    mysql_num_rows$result ) > ){
      die( 
    'You already voted for this person today.' ); 
    }

    $givemoney rand(11500); 
    $query2 'INSERT INTO clicks (ip , id) VALUES ("' $ip '" , ' $id ')'
    $result2 mysql_queryquery2 ) or die( 'Could not add click.' ); 
    $query3 'UPDATE players SET credits = credits + ' $givemoney ' WHERE id=' $id
    $result3 mysql_query$query3 ) or die( 'Could not update player.' ); 
    $query4 'SELECT * FROM players WHERE id=' $id
    $result4 mysql_query$query4 ) or die( 'Could not select player.' ); 
    $userArray msyql_fetch_array$result4 ); 
    die( 
    $userArray['user'] . ' just got ' $givemoney ); 

    ?>
    Last edited by Viflux; Nov 9, 2004 at 10:05. Reason: Updated...

  12. #37
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still "Could not add click."
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  13. #38
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add an echo statement to display $query2

    Also, what does your db structure for the clicks table look like?


    Off Topic:

    Lucky it's a very slow day at work

  14. #39
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    INSERT INTO clicks (ip , id) VALUES ("81.218.107.147" , "1")

    the structure is
    id int(11)
    ip varchar(11)
    Off Topic:

    Run a site? over 1,000 uniques a day? PM me for link exchange.

  15. #40
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Can I just clarify....
    You want a player to get a click from a link and get a random number of points from that IP address.
    The IP can then not click again on that link but can click another link to give another player credits?

    Yes?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  16. #41
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  17. #42
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add the mysql_error() function to all of your die statements. This will tell you exactly what the SQL engine is receiving and what it thinks is wrong.
    Also, echo out the query before calling each mysql_query. You might just spot what is wrong.

    Hope this helps

  18. #43
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    right then.
    PHP Code:
    include("config.php");
    $ip $_SERVER['REMOTE_ADDR'];
    $id $_GET['id'];
    $clicks mysql_query("select * from clicks where ip='$ip' AND id='$id'") or die(mysql_error());
    $rows mysql_num_rows($clicks);
    if (
    $rows==0) {
    $givemoney rand(11500);
    mysql_query("insert into clicks (ip, id) values('$ip','$id')") or die("Could not add click.");
    mysql_query("update players set credits=credits+'$givemoney' where id=$id");
    $userstat mysql_query("select * from players where id=$id");
    $row_stat mysql_fetch_assoc($userstat); 
    echo 
    $id"just got ".$givemoney" credits.";
    } else {
    echo 
    "Your credits have already been added to this ID";

    Gives you click and add IP/ id combo into database but can then click a different ID.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  19. #44
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swdev
    Add the mysql_error() function to all of your die statements. This will tell you exactly what the SQL engine is receiving and what it thinks is wrong.
    Also, echo out the query before calling each mysql_query. You might just spot what is wrong.

    Hope this helps
    its a code problem....
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  20. #45
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ
    right then.
    PHP Code:
    include("config.php");
    $ip $_SERVER['REMOTE_ADDR'];
    $id $_GET['id'];
    $clicks mysql_query("select * from clicks where ip='$ip' AND id='$id'") or die(mysql_error());
    $rows mysql_num_rows($clicks);
    if (
    $rows==0) {
    $givemoney rand(11500);
    mysql_query("insert into clicks (ip, id) values('$ip','$id')") or die("Could not add click.");
    mysql_query("update players set credits=credits+'$givemoney' where id=$id");
    $userstat mysql_query("select * from players where id=$id");
    $row_stat mysql_fetch_assoc($userstat); 
    echo 
    $id"just got ".$givemoney" credits.";
    } else {
    echo 
    "Your credits have already been added to this ID";

    Gives you click and add IP/ id combo into database but can then click a different ID.....
    it still gives any one click as much as he likes...
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  21. #46
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try my updated code (last post with code)...

    I was adding the id as a string, I have removed the parenthesis to add it as an int.

    Also, if it still isn't working, it is a good idea to add mysql_error() onto the die() statements. If the die() is ever executed, it's because the query failed. Adding that function to the message will tell you why it failed.

  22. #47
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i just noticed that the ip on the mysql database save only 11 chars... damn i forgot to give it more then 11 oops...? sorry every one... ill change it and try again
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  23. #48
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    spikeZ - after i changed it, the ip limit chars, your code works great, thanks.
    Viflux - im sure your code is working great too, thanks all of you!
    really thanks alot, its just because im such an idiot, the codes didn't worked, thanks and sorry for the hassle
    Run a site? over 1,000 uniques a day? PM me for link exchange.

  24. #49
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol...

    make sure to make it at least 15

  25. #50
    Crazy Webmaster Cr0CX's Avatar
    Join Date
    Dec 2003
    Location
    WWW
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah... i made it 20... "just in case"... thanks!!
    Run a site? over 1,000 uniques a day? PM me for link exchange.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •