What a hell am i doing wrong ? !! please help !

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    What a hell am i doing wrong ? !! please help !

    i made a script that counts unique visits and user/ip visits the problem is that on my host it counts +2 instead +1 how its written in the script watch and give a reply

    PHP Code:
    <?php
    // Your MySQL database host
    $db_host "localhost";
    // Your MySQL database username
    $db_user "user";
    // Your MySQL database password
    $db_pass "password";
    // Your MySQL database name
    $db_name "name";

    $conexiune mysql_connect($db_host,$db_user,$db_pass) or die('I can\'t connect to MySQL server!');
    $conexiune1 mysql_select_db($db_name$conexiune) or die('Database cannot be found');
    //if(!$conexiune1){die("Sorry to many conection it is possible that we are flooded");}



    $server=$_SERVER['REMOTE_ADDR'];


    $check=mysql_fetch_array(mysql_query("SELECT ipuniq FROM ip_logss WHERE ipuniq='".mysql_real_escape_string($server)."'"));
    $cnt=mysql_fetch_array(mysql_query("SELECT total_per_user FROM ip_logss WHERE ipuniq='".mysql_real_escape_string($server)."'"));

    $total_per_user=$cnt[0]+1;

    if(empty(
    $check[0])){$proc_index=mysql_query("INSERT INTO  ip_logss SET ipuniq='".mysql_real_escape_string($server)."'");}

    else{
    $proc_total=mysql_query("UPDATE ip_logss SET total_per_user=".$total_per_user." WHERE ipuniq='".mysql_real_escape_string($server)."' ");}

    $check_count mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ip_logss"));


    echo
    '<small>ToTal Unique Hits '.$check_count[0].'</small><br/><small>Your visits here '.$cnt[0].'</small><br/>'

    ?>

    mysql database here

    Code:
    CREATE TABLE IF NOT EXISTS `ip_logss` (
      `ipuniq` varchar(500) NOT NULL DEFAULT '',
      `total_per_user` varchar(500) NOT NULL DEFAULT '',
      PRIMARY KEY (`ipuniq`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    here is the link to the script running http://celx.eu/visits.php

    Added after 6 minutes:

    btw when visiting http://celx.eu/visits.php give 3 or more reloads on page and see how it acts ,,
    Last edited by just_m3.; 24.06.11, 19:31.
    This is ten percent luck, twenty percent skill
    Fifteen percent concentrated power of will
    Five percent pleasure, fifty percent pain

    And a hundred percent reason to remember the name!

    #2
    could try:
    PHP Code:
    else{$proc_total=mysql_query("UPDATE ip_logss SET total_per_user=total_per_user+1 WHERE ipuniq='".mysql_real_escape_string($server)."' ");} 
    p.s your probably better off setting:
    `ipuniq` varchar(500) NOT NULL DEFAULT '',
    `total_per_user` varchar(500) NOT NULL DEFAULT '',


    to
    `total_per_user` int(10) NOT NULL DEFAULT '0',
    `ipuniq` varchar(15) NOT NULL DEFAULT '',
    Last edited by something else; 24.06.11, 19:41.

    Comment


      #3
      finally it works thanxxxx :p

      Added after 6 minutes:

      it's started to add+2 again ) lol i don't know what is wrong i gived the code to someone else to try it on other server and its working fine ..
      Last edited by just_m3.; 24.06.11, 19:54.
      This is ten percent luck, twenty percent skill
      Fifteen percent concentrated power of will
      Five percent pleasure, fifty percent pain

      And a hundred percent reason to remember the name!

      Comment


        #4
        i was having the same problem on my server it seemed the only way i could fix it would be to make the 1 a variable
        Code:
        $total_per_user=$cnt[0]+1;
        so try change it to
        Code:
        $add = 1;
        $total_per_user=$cnt[0]+$add;
        Creator of
        Epix.Mobi

        Keep an Eye on us Big things coming soon!!!!
        Need something for your site hit me up here

        http://coding-talk.com/forum/main-fo...r-your-wapsite

        Comment


          #5
          Well try to limit it.

          PHP Code:
           $check_count mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ip_logss Limit 1")); 
          <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

          Comment


            #6
            PHP Code:
             $check_count mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ip_logss Limit 1")); 
            $check_count is for counting unique visits why should i limit ?
            This is ten percent luck, twenty percent skill
            Fifteen percent concentrated power of will
            Five percent pleasure, fifty percent pain

            And a hundred percent reason to remember the name!

            Comment


              #7
              Limit query, it counts 2+2... on refresh so limit it to 1. Try it.
              <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

              Comment


                #8
                Originally posted by Loony View Post
                i was having the same problem on my server it seemed the only way i could fix it would be to make the 1 a variable
                Code:
                $total_per_user=$cnt[0]+1;
                so try change it to
                Code:
                $add = 1;
                $total_per_user=$cnt[0]+$add;

                i already tried that it's not working i think my host is dumb ..
                This is ten percent luck, twenty percent skill
                Fifteen percent concentrated power of will
                Five percent pleasure, fifty percent pain

                And a hundred percent reason to remember the name!

                Comment


                  #9
                  if that doesnt work try to unset($cnt); be4 running all ur querys again
                  Creator of
                  Epix.Mobi

                  Keep an Eye on us Big things coming soon!!!!
                  Need something for your site hit me up here

                  http://coding-talk.com/forum/main-fo...r-your-wapsite

                  Comment


                    #10
                    neah .. ain't working i think i will just use unique counter and thats it .. at least untill i change my host thanks all
                    This is ten percent luck, twenty percent skill
                    Fifteen percent concentrated power of will
                    Five percent pleasure, fifty percent pain

                    And a hundred percent reason to remember the name!

                    Comment


                      #11
                      use histats.com , alternative ways , better results :-)

                      whatever , WapPortal Free wap downloads work , increment with one on every refresh . just on begin dont show anything so change DEFAULT do 0.

                      one short question : Do you think your users are really interested in this statistics ?!
                      Unamos los corazones,hoy todos somos multicolores!

                      Comment


                        #12
                        Originally posted by morency View Post
                        use histats.com , alternative ways , better results :-)

                        whatever , WapPortal Free wap downloads work , increment with one on every refresh . just on begin dont show anything so change DEFAULT do 0.

                        one short question : Do you think your users are really interested in this statistics ?!
                        DEFAULT is changed to 0 ,, some of them may be don't you think ? ) anyway i removed that .. , and about counting, sometimes counts right and then it gets dizzy at least i think :D ... it's a server side error most sure // about 2 months ago had an unbelievable server side error so when i requested user ip was showing me the host ip more precisely my site ip .. can you believe that ?
                        Last edited by just_m3.; 24.06.11, 21:09.
                        This is ten percent luck, twenty percent skill
                        Fifteen percent concentrated power of will
                        Five percent pleasure, fifty percent pain

                        And a hundred percent reason to remember the name!

                        Comment


                          #13
                          it sounds like you have registered globals on :P

                          Comment


                            #14
                            anyway the final script working (not on my host ) ..

                            is here
                            Attached Files
                            This is ten percent luck, twenty percent skill
                            Fifteen percent concentrated power of will
                            Five percent pleasure, fifty percent pain

                            And a hundred percent reason to remember the name!

                            Comment


                              #15
                              How is host suppose to affect that? >_>
                              And sometime working and sometime not, means a single request to that page might be going twice.. maybe network issue
                              Follow me @ksg91 | My Blog: http://ksg91.com | Nokia Blog: http://NokiaTips.in

                              Comment

                              Working...
                              X