PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/classes/users.php on line 162
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/classes/user.php on line 62


Here is users.php

<?php
class user{  
    var $user=array();
    var $random_id;
    var $random_link;
    var $currentpoint;
    var $minspoint;
    var $pluspoint;
    var $timeout;
    var $ip;
    var $cookies;
    var $active_enter;
    var $day;
    var $month;
    var $year;
    var $pointone;
    var $invite_point;
    var $email;
    var $points=array();
    var $userpoint;
    var $openerwidth;
    var $openerheight;
    var $banned;
    function username($id){
        $this->month=date('m');
        $this->day=date('d');
        $this->year=date('y');
        $query=mysql_query(" select * from user where id=".$id);
        while($fetch=mysql_fetch_array($query)){
        $this->banned=$fetch['banned'];
        $this->timeout=$fetch['time'];
        $this->cookies=$fetch['cookies'];
        $this->active_enter=$fetch['active_enter'];
        $this->user['email']=$fetch['email'];
        $this->user['username']=$fetch['username'];
        $this->user['link_site']=$fetch['link_site'];
        $this->user['name_site']=$fetch['name_site'];
        $this->user['active_code']=$fetch['active_code'];
        $this->user['entertainment']=$fetch['entertainment'];
        }
        }

    function getopenerpro(){
        $query=mysql_query(" select * from opener limit 0,1 ");
        $fetch=mysql_fetch_array($query);
        if($fetch){
            $this->openerwidth=$fetch['with_opener'];
            $this->openerheight=$fetch['height_opener'];
        }
    }

     

    function currentPoint($id){  
        $this->day=date('d');
            $query=mysql_query(" select day".$this->day." from days where iduser=".$id);
            $fetch=mysql_fetch_array($query);
            $this->currentpoint=$fetch[0];
          }
   function userpoint($id){
            $query=mysql_query("select point from user where id=".$id);
            $fetch=mysql_fetch_array($query);
            $this->userpoint=$fetch['point'];
   }       
          function getsetting(){
            $query=mysql_query(" select * from admin_setting where id_setting=1");
            $fetch=mysql_fetch_array($query);
            if(mysql_num_rows($query)>0){
                $this->pointone=$fetch['pointone'];
                $this->invite_point=$fetch['invite_point'];
                $this->email=$fetch['email'];
                
            }
          }
          
          function setpoint($userid,$point=1){ 
            if(date('d')=='01'){
                if($userpluspoint <> 0){
               $sql="UPDATE `days` SET `day01` = '0',
`day02` = '0',
`day03` = '0',
`day04` = '0',
`day05` = '0',
`day06` = '0',
`day07` = '0',
`day08` = '0',
`day09` = '0',
`day10` = '0',
`day11` = '0',
`day12` = '0',
`day13` = '0',
`day14` = '0',
`day15` = '0',
`day16` = '0',
`day17` = '0',
`day18` = '0',
`day19` = '0',
`day20` = '0',
`day21` = '0',
`day22` = '0',
`day23` = '0',
`day24` = '0',
`day25` = '0',
`day26` = '0',
`day27` = '0',
`day28` = '0',
`day29` = '0',
`day30` = '0',
`day31` = '0',
`day_01` = '0',
`day_02` = '0',
`day_03` = '0',
`day_04` = '0',
`day_05` = '0',
`day_06` = '0',
`day_07` = '0',
`day_08` = '0',
`day_09` = '0',
`day_10` = '0',
`day_11` = '0',
`day_12` = '0',
`day_13` = '0',
`day_14` = '0',
`day_15` = '0',
`day_16` = '0',
`day_17` = '0',
`day_18` = '0',
`day_19` = '0',
`day_20` = '0',
`day_21` = '0',
`day_22` = '0',
`day_23` = '0',
`day_24` = '0',
`day_25` = '0',
`day_26` = '0',
`day_27` = '0',
`day_28` = '0',
`day_29` = '0',
`day_30` = '0',
`day_31` = '0' WHERE `day_id` =".$userid;
mysql_query($sql);
mysql_query("update user set point=0 where id=".$userid);

        }
            }
            $this->currentPoint($userid);
            $this->pluspoint=intval($this->currentpoint)+$point;
            $this->userpoint($userid);
            $userpluspoint=$this->userpoint+$point;
            $query=mysql_query(" update days set day".$this->day."=".$this->pluspoint." where iduser=".$userid);
            $query2=mysql_query("update user set point=".$userpluspoint." where id=".$userid);
            if($query){
                  return true;
                }else{
                     return false;
                 }
             }
          

    function minsPoint($iduser='0'){
        $query=mysql_query(" select day_".$this->day." from days where iduser=".$iduser);
        $fetch=mysql_fetch_array($query);
        $minspoint=$fetch[0];
        $this->userpoint($iduser);
        $userminspoint=$this->userpoint-$this->points['minspoint'];
        $minspoint=$minspoint+intval($this->points['minspoint']);
        $query=mysql_query(" update days set day_".$this->day."=".$minspoint." where iduser=".$iduser );
        $query2=mysql_query("update user set point=".$userminspoint." where id=".$iduser );
        if($query){
            return true;
        }else{
            return false;
        }
    }
    function gensite($idsite='0',$minspoint='1'){

        if($this->active_enter=='yes'){
            $entertainment=0;
        }else{
            $entertainment=1;
        }
        $query=mysql_query("select * from user where entertainment=".$entertainment." and id <> ".$idsite." and point >=".$minspoint." order by rand() limit 0,1");
        $fetch=mysql_fetch_array($query);
            $this->random_id=$fetch['id'];                   
            $this->random_link=$fetch['link_site'];
            }
    function checkuser($username){
        $query=mysql_query("select * from user where username='".$username."'");
        $count=mysql_num_rows($query);
        if($count > 0){
            return true;
        }else{
            return false;
        }
    }
    function checksite($sitename){
        $aa=split('\.',$sitename);
        
        $query=mysql_query("select * from user ");
        while($fetch=mysql_fetch_array($query)){
            $aa2=array();
            $aa2=split('\.',$fetch['link_site']);
           
            if($aa2[1]==$aa[1]){
               break; 
            }
        }
         
            if($aa2[1]==$aa[1]){
               return true; 
            }else{
               return false; 
            }
       
        
    }
    function getiduser($username){
      $query=mysql_query("select * from user where username='".$username."'");
      $fetch=mysql_fetch_array($query);
      return $fetch['id'];
    }

    function checkvisitor(){
        $this->ip=$_SERVER["REMOTE_ADDR"];
        $date_ip=date('d/m/y');
        $query=mysql_query("SELECT * FROM `check`  where ip='".$this->ip."' and date_ip='".$date_ip."'");
        $count=mysql_num_rows($query);
        if($count > 0){
            return false;
        }else{
            $query=mysql_query(" INSERT INTO `check` ( `id` , `ip`,`date_ip`)VALUES ('', '".$this->ip."','".$date_ip."')");
          return true;
        }
        
    }
    function checklogin($username,$password){
        $query=mysql_query("select * from user where username='".$username."' and password='".md5($password)."'");
        $count=mysql_num_rows($query);
        if($count > 0){
               $fetch=mysql_fetch_array($query);
               $this->user['username']=$fetch['username'];
               $this->user['userid']=$fetch['id'];
               $this->user['point']=$fetch['point'];
               $this->user['link_site']=$fetch['link_site'];
               $this->user['active']=$fetch['active'];
               $this->user['active_code']=$fetch['active_code'];
               $this->user['banned']=$fetch['banned'];
               return true;
        }else{
            return false;
        }
  
    }  
        function getinfo($iduser){
        $query=mysql_query("select * from user where id=".$iduser);
        $count=mysql_num_rows($query);
        if($count > 0){
               $fetch=mysql_fetch_array($query);
               $this->user['username']=$fetch['username'];
               $this->user['point']=$fetch['point'];
               $this->user['link_site']=$fetch['link_site'];
               return true;
        }else{
            return false;
        }
  
    }     
    function updateSetting($id,$link_site,$cookies,$entertainment,$active_enter='yes'){
        $query=mysql_query(" update user set link_site='".$link_site."', cookies='".$cookies."', entertainment=".$entertainment.", active_enter='".$active_enter."' where id=".$id);
        if($query){
            return true;   
        }else{
            return false;
        }     
    }
    function gencode($id){
        $code= '
<script type="text/javascript" src="http://www.opener-sites.ppc2you.com/pop-'.$id.'.js"></script>
';
return $code;
    }
    
    function createpoint($iduser){
        $day=date('d');
        $month=date('m');
        $year=date('y');
        $query=mysql_query(" insert into days(day".$day.",iduser)values(0,".$iduser.") ");
        if($query){
            $query2=mysql_query(" insert into months(month".$month.",iduser)values(0,".$iduser.") ");
                 if($query2){
                 $query3=mysql_query(" insert into years(year20".$year.",iduser)values(0,'".$iduser."') ");
            }
        }
    }
    
    function sumpointmonth($iduser){
        $month=date('m');
        $day=date('d');
       if($day==1){ 
        $query=mysql_query("select month".$month." from months where iduser=".$iduser." limit 0,1");
           $fetch=mysql_fetch_array($query);
         if($fetch[0]==0){        
            $query=mysql_query("select day01+day02+day03+day04+day05+day06+day07+day08+day09+day10+day11+day12+day13+day14+day15+day16+day17+day18+day19+day20+day21+day22+day23+day24+day25+day26+day27+day28+day29+day30+day31 from days where iduser=".$iduser);
            $fetch=mysql_fetch_array($query);
            $sum_days=$fetch[0];
            $query2=mysql_query("select day_01+day_02+day_03+day_04+day_05+day_06+day_07+day_08+day_09+day_10+day_11+day_12+day_13+day_14+day_15+day_16+day_17+day_18+day_19+day_20+day_21+day_22+day_23+day_24+day_25+day_26+day_27+day_28+day_29+day_30+day_31 from days where iduser=".$iduser);
            $fetch2=mysql_fetch_array($query2);
            $sum_days_=$fetch2[0];
            $query=mysql_query(" update months set month".$month."=".$sum_days." , month_".$month."=".$sum_days_." where iduser=".$iduser);
            }
       }              
    }
    function sumpointday($opener='1'){
       $opener=intval($opener);
       $day=date('d')-1;
if(strlen(date('d')-01)==1){
     $dayy='0'.$day;
}else{
   $dayy=$day;  
}
        
       if($dayy <> 0){
        
          $query=mysql_query("select sum(day".$dayy.") from days");
          $fetch=mysql_fetch_array($query);
          if($opener<>0){
            return $fetch[0]/$opener;
          }else{
            return 0;
          }
          
          
       }
    }
        function sumsite(){                
          $query=mysql_query("select count(id) from user");
          $fetch=mysql_fetch_array($query);
          return $fetch[0];                 
    }
        function sumpointyear($iduser){
        $year='year20'.date('y');   
        $year2='year_20'.date('y');    
        $query=mysql_query("select ".$year." from years where iduser=".$iduser." limit 0,1");
        $fetch=mysql_fetch_array($query);
         if($fetch[0]==0){        
            $query=mysql_query("select month01+month02+month03+month04+month05+month06+month07+month08+month09+month10+month11+month12 from months where iduser=".$iduser);
            $fetch=mysql_fetch_array($query);
            $sum_months=$fetch[0];
            $query2=mysql_query("select month_01+month_02+month_03+month_04+month_05+month_06+month_07+month_08+month_09+month_10+month_11+month_12 from months where iduser=".$iduser);
            $fetch2=mysql_fetch_array($query2);
            $sum_months_=$fetch2[0];
            $query3=mysql_query(" update years set ".$year."=".$sum_months." , ".$year2."=".$sum_months_." where iduser=".$iduser);
            }
             
    }
    function query($sql)
    {
        $rs = mysql_query($sql);
      
        return $rs;
    }
    function select($sql)
    {
        $rs = $this->query($sql);
        if (!$rs) {
            return;
        }

        @$num_rows = mysql_numrows($rs);

        if (($rs) && ($num_rows > 0)) {

            $data_array = array();
            while ($row = mysql_fetch_row($rs)) {
                $data_array[] = $row;
            }
            mysql_free_result($rs);

            return $data_array;
        } else {
            return false;
        }
    }
      function is_table($tabname)
    {
        $tabname = trim($tabname);
        if (empty($tabname))
            return false;
        $result = $this->select("SHOW TABLES FROM " . namedb);
        if (is_array($result))
            foreach ($result as $key => $value) {
                if (trim($result[$key][0]) == $tabname) {
                    return true;
                    break;
                }
            }
        return false;
    }
    function is_field($tablename, $field)
    {
        $tablename = trim($tablename);
        $field = trim($field);
        if (empty($tablename) || empty($field))
            return false;
        if (!$this->is_table($tablename))
            return false;
        $result = $this->select("SHOW COLUMNS FROM $tablename");
        if (is_array($result))
            foreach ($result as $key => $value) {
                if (trim($result[$key][0]) == $field) {
                    return true;
                    break;
                }
            }
        return false;
    }
    function checkpass($userid,$password){
       $query=mysql_query("select * from user where id=".$userid." and password='".md5($password)."'");
       $count=mysql_num_rows($query);
       if($count >0){
            return true;
       }else{
            return false;
       }
    }
    function changepassword($userid,$newpassword){
        $query=mysql_query(" update user set password='".md5($newpassword)."' where id=".$userid);
        if($query){
            return true;
        }else{
            return false;
        }
    }
    function is_number($number){
    $pattern = "^[0-9]+$";
    if(eregi($pattern,$number)){
        return true; 
    }else{
        return false; 
    }
}
    function updatedata($userid,$username,$name_site){
        $sql=" update user set username='".$username."' ,  name_site='".$name_site."' where id=".$userid;
        $query=mysql_query($sql);
        if($query){
            return true;
        }else{
            return false;
        }
        
    }
    function statistics($userid){
        $day=date('d');
        for($i=$day;$i>0;$i--){
            if($i=='01'and strlen($i)==2){
               $select.= "day".$i;
               break;
            }
             if($i==1){
               $select.= "day0".$i;
               break;
            }
            if(substr($i,0,1)==0){
                $select.='day'.$i." , ";
            }elseif(strlen($i)==2){
                $select.='day'.$i." , ";
            }else{
                   $select.='day0'.$i." , ";
            }
            
        }
       
        $select_=preg_replace('/day/','day_',$select);
        $query=mysql_query( " select  ".$select.",".$select_." from days where iduser=".$userid) ;
        $fetch=mysql_fetch_array($query);
        $col=array();
        $col[]=$fetch;
        return $col;

    }
        function statistics2($userid){
        $day=date('d');
        for($i=$day;$i>0;$i--){
            if($i==01){
               $select.= "day_0".$i;
               break;
            }
            if(substr($i,0,1)==0){
                $select.='day_'.$i." , ";
            }elseif(strlen($i)==2){
                $select.='day_'.$i." , ";
            }else{
                   $select.='day_0'.$i." , ";
            }
            
        }
       
        $select_=preg_replace('/day/','day_',$select);
        $query=mysql_query( " select  ".$select.",".$select_." from days where iduser=".$userid) ;
        $fetch=mysql_fetch_array($query);
        $col=array();
        $col[]=$fetch;
        return $col;

    }
        function getpointsetting(){
        $sql=mysql_query('select * from points where id=1');
        $fetch=mysql_fetch_array($sql);
        $this->points['point']=$fetch['point'];
        $this->points['minspoint']=$fetch['minspoint'];
        $this->points['invitepoint']=$fetch['invitepoint'];
        $this->points['opener']=$fetch['opener'];
        
    }
}

$user=new user();

?>

can any one help me to fix this Warning

Recommended Answers

All 20 Replies

I'm seeing a lot of mysql_query(), but where is the mysql_connect() ?

it is on config.php file this is it

<?php
session_start();
$host='localhost';
$usernamedb='db_user';
$passdb='db_password';
$dbname='db_name';
mysql_connect($host,$usernamedb,$passdb);
mysql_select_db($dbname);
mysql_query('SET NAMES cp1256');
define('namedb',$dbname,true);
include('classes/users.php');
?>

please dear help me

Then both queries fail. Add or die(mysql_error()) to the mysql query to see the error message.

If only you read readme sticky
It have the problem. Link is here

Then both queries fail. Add or die(mysql_error()) to the mysql query to see the error message.

dear iam new with php can you tell me how to add it please SNIP

commented: Please try and get the message about not asking for private help here -2

See the link estevemd posted.

dear where i have to add mysql_error in config.php or users.php

can you add it for me iam new with this


here is config.php
add it to me dear

<?php
session_start();
$host='localhost';
$usernamedb='db_user';
$passdb='db_password';
$dbname='db_name';
mysql_connect($host,$usernamedb,$passdb);
mysql_select_db($dbname);
mysql_query('SET NAMES cp1256');
define('namedb',$dbname,true);
include('classes/users.php');
?>

also if i have to add it in users.php
please dear add it for me i dont know how and where i have to add it

<?php
class user{  
    var $user=array();
    var $random_id;
    var $random_link;
    var $currentpoint;
    var $minspoint;
    var $pluspoint;
    var $timeout;
    var $ip;
    var $cookies;
    var $active_enter;
    var $day;
    var $month;
    var $year;
    var $pointone;
    var $invite_point;
    var $email;
    var $points=array();
    var $userpoint;
    var $openerwidth;
    var $openerheight;
    var $banned;
    function username($id){
        $this->month=date('m');
        $this->day=date('d');
        $this->year=date('y');
        $query=mysql_query(" select * from user where id=".$id);
        while($fetch=mysql_fetch_array($query)){
        $this->banned=$fetch['banned'];
        $this->timeout=$fetch['time'];
        $this->cookies=$fetch['cookies'];
        $this->active_enter=$fetch['active_enter'];
        $this->user['email']=$fetch['email'];
        $this->user['username']=$fetch['username'];
        $this->user['link_site']=$fetch['link_site'];
        $this->user['name_site']=$fetch['name_site'];
        $this->user['active_code']=$fetch['active_code'];
        $this->user['entertainment']=$fetch['entertainment'];
        }
        }

    function getopenerpro(){
        $query=mysql_query(" select * from opener limit 0,1 ");
        $fetch=mysql_fetch_array($query);
        if($fetch){
            $this->openerwidth=$fetch['with_opener'];
            $this->openerheight=$fetch['height_opener'];
        }
    }

     

    function currentPoint($id){  
        $this->day=date('d');
            $query=mysql_query(" select day".$this->day." from days where iduser=".$id);
            $fetch=mysql_fetch_array($query);
            $this->currentpoint=$fetch[0];
          }
   function userpoint($id){
            $query=mysql_query("select point from user where id=".$id);
            $fetch=mysql_fetch_array($query);
            $this->userpoint=$fetch['point'];
   }       
          function getsetting(){
            $query=mysql_query(" select * from admin_setting where id_setting=1");
            $fetch=mysql_fetch_array($query);
            if(mysql_num_rows($query)>0){
                $this->pointone=$fetch['pointone'];
                $this->invite_point=$fetch['invite_point'];
                $this->email=$fetch['email'];
                
            }
          }
          
          function setpoint($userid,$point=1){ 
            if(date('d')=='01'){
                if($userpluspoint <> 0){
               $sql="UPDATE `days` SET `day01` = '0',
`day02` = '0',
`day03` = '0',
`day04` = '0',
`day05` = '0',
`day06` = '0',
`day07` = '0',
`day08` = '0',
`day09` = '0',
`day10` = '0',
`day11` = '0',
`day12` = '0',
`day13` = '0',
`day14` = '0',
`day15` = '0',
`day16` = '0',
`day17` = '0',
`day18` = '0',
`day19` = '0',
`day20` = '0',
`day21` = '0',
`day22` = '0',
`day23` = '0',
`day24` = '0',
`day25` = '0',
`day26` = '0',
`day27` = '0',
`day28` = '0',
`day29` = '0',
`day30` = '0',
`day31` = '0',
`day_01` = '0',
`day_02` = '0',
`day_03` = '0',
`day_04` = '0',
`day_05` = '0',
`day_06` = '0',
`day_07` = '0',
`day_08` = '0',
`day_09` = '0',
`day_10` = '0',
`day_11` = '0',
`day_12` = '0',
`day_13` = '0',
`day_14` = '0',
`day_15` = '0',
`day_16` = '0',
`day_17` = '0',
`day_18` = '0',
`day_19` = '0',
`day_20` = '0',
`day_21` = '0',
`day_22` = '0',
`day_23` = '0',
`day_24` = '0',
`day_25` = '0',
`day_26` = '0',
`day_27` = '0',
`day_28` = '0',
`day_29` = '0',
`day_30` = '0',
`day_31` = '0' WHERE `day_id` =".$userid;
mysql_query($sql);
mysql_query("update user set point=0 where id=".$userid);

        }
            }
            $this->currentPoint($userid);
            $this->pluspoint=intval($this->currentpoint)+$point;
            $this->userpoint($userid);
            $userpluspoint=$this->userpoint+$point;
            $query=mysql_query(" update days set day".$this->day."=".$this->pluspoint." where iduser=".$userid);
            $query2=mysql_query("update user set point=".$userpluspoint." where id=".$userid);
            if($query){
                  return true;
                }else{
                     return false;
                 }
             }
          

    function minsPoint($iduser='0'){
        $query=mysql_query(" select day_".$this->day." from days where iduser=".$iduser);
        $fetch=mysql_fetch_array($query);
        $minspoint=$fetch[0];
        $this->userpoint($iduser);
        $userminspoint=$this->userpoint-$this->points['minspoint'];
        $minspoint=$minspoint+intval($this->points['minspoint']);
        $query=mysql_query(" update days set day_".$this->day."=".$minspoint." where iduser=".$iduser );
        $query2=mysql_query("update user set point=".$userminspoint." where id=".$iduser );
        if($query){
            return true;
        }else{
            return false;
        }
    }
    function gensite($idsite='0',$minspoint='1'){

        if($this->active_enter=='yes'){
            $entertainment=0;
        }else{
            $entertainment=1;
        }
        $query=mysql_query("select * from user where entertainment=".$entertainment." and id <> ".$idsite." and point >=".$minspoint." order by rand() limit 0,1");
        $fetch=mysql_fetch_array($query);
            $this->random_id=$fetch['id'];                   
            $this->random_link=$fetch['link_site'];
            }
    function checkuser($username){
        $query=mysql_query("select * from user where username='".$username."'");
        $count=mysql_num_rows($query);
        if($count > 0){
            return true;
        }else{
            return false;
        }
    }
    function checksite($sitename){
        $aa=split('\.',$sitename);
        
        $query=mysql_query("select * from user ");
        while($fetch=mysql_fetch_array($query)){
            $aa2=array();
            $aa2=split('\.',$fetch['link_site']);
           
            if($aa2[1]==$aa[1]){
               break; 
            }
        }
         
            if($aa2[1]==$aa[1]){
               return true; 
            }else{
               return false; 
            }
       
        
    }
    function getiduser($username){
      $query=mysql_query("select * from user where username='".$username."'");
      $fetch=mysql_fetch_array($query);
      return $fetch['id'];
    }

    function checkvisitor(){
        $this->ip=$_SERVER["REMOTE_ADDR"];
        $date_ip=date('d/m/y');
        $query=mysql_query("SELECT * FROM `check`  where ip='".$this->ip."' and date_ip='".$date_ip."'");
        $count=mysql_num_rows($query);
        if($count > 0){
            return false;
        }else{
            $query=mysql_query(" INSERT INTO `check` ( `id` , `ip`,`date_ip`)VALUES ('', '".$this->ip."','".$date_ip."')");
          return true;
        }
        
    }
    function checklogin($username,$password){
        $query=mysql_query("select * from user where username='".$username."' and password='".md5($password)."'");
        $count=mysql_num_rows($query);
        if($count > 0){
               $fetch=mysql_fetch_array($query);
               $this->user['username']=$fetch['username'];
               $this->user['userid']=$fetch['id'];
               $this->user['point']=$fetch['point'];
               $this->user['link_site']=$fetch['link_site'];
               $this->user['active']=$fetch['active'];
               $this->user['active_code']=$fetch['active_code'];
               $this->user['banned']=$fetch['banned'];
               return true;
        }else{
            return false;
        }
  
    }  
        function getinfo($iduser){
        $query=mysql_query("select * from user where id=".$iduser);
        $count=mysql_num_rows($query);
        if($count > 0){
               $fetch=mysql_fetch_array($query);
               $this->user['username']=$fetch['username'];
               $this->user['point']=$fetch['point'];
               $this->user['link_site']=$fetch['link_site'];
               return true;
        }else{
            return false;
        }
  
    }     
    function updateSetting($id,$link_site,$cookies,$entertainment,$active_enter='yes'){
        $query=mysql_query(" update user set link_site='".$link_site."', cookies='".$cookies."', entertainment=".$entertainment.", active_enter='".$active_enter."' where id=".$id);
        if($query){
            return true;   
        }else{
            return false;
        }     
    }
    function gencode($id){
        $code= '
<script type="text/javascript" src="http://www.opener-sites.ppc2you.com/pop-'.$id.'.js"></script>
';
return $code;
    }
    
    function createpoint($iduser){
        $day=date('d');
        $month=date('m');
        $year=date('y');
        $query=mysql_query(" insert into days(day".$day.",iduser)values(0,".$iduser.") ");
        if($query){
            $query2=mysql_query(" insert into months(month".$month.",iduser)values(0,".$iduser.") ");
                 if($query2){
                 $query3=mysql_query(" insert into years(year20".$year.",iduser)values(0,'".$iduser."') ");
            }
        }
    }
    
    function sumpointmonth($iduser){
        $month=date('m');
        $day=date('d');
       if($day==1){ 
        $query=mysql_query("select month".$month." from months where iduser=".$iduser." limit 0,1");
           $fetch=mysql_fetch_array($query);
         if($fetch[0]==0){        
            $query=mysql_query("select day01+day02+day03+day04+day05+day06+day07+day08+day09+day10+day11+day12+day13+day14+day15+day16+day17+day18+day19+day20+day21+day22+day23+day24+day25+day26+day27+day28+day29+day30+day31 from days where iduser=".$iduser);
            $fetch=mysql_fetch_array($query);
            $sum_days=$fetch[0];
            $query2=mysql_query("select day_01+day_02+day_03+day_04+day_05+day_06+day_07+day_08+day_09+day_10+day_11+day_12+day_13+day_14+day_15+day_16+day_17+day_18+day_19+day_20+day_21+day_22+day_23+day_24+day_25+day_26+day_27+day_28+day_29+day_30+day_31 from days where iduser=".$iduser);
            $fetch2=mysql_fetch_array($query2);
            $sum_days_=$fetch2[0];
            $query=mysql_query(" update months set month".$month."=".$sum_days." , month_".$month."=".$sum_days_." where iduser=".$iduser);
            }
       }              
    }
    function sumpointday($opener='1'){
       $opener=intval($opener);
       $day=date('d')-1;
if(strlen(date('d')-01)==1){
     $dayy='0'.$day;
}else{
   $dayy=$day;  
}
        
       if($dayy <> 0){
        
          $query=mysql_query("select sum(day".$dayy.") from days");
          $fetch=mysql_fetch_array($query);
          if($opener<>0){
            return $fetch[0]/$opener;
          }else{
            return 0;
          }
          
          
       }
    }
        function sumsite(){                
          $query=mysql_query("select count(id) from user");
          $fetch=mysql_fetch_array($query);
          return $fetch[0];                 
    }
        function sumpointyear($iduser){
        $year='year20'.date('y');   
        $year2='year_20'.date('y');    
        $query=mysql_query("select ".$year." from years where iduser=".$iduser." limit 0,1");
        $fetch=mysql_fetch_array($query);
         if($fetch[0]==0){        
            $query=mysql_query("select month01+month02+month03+month04+month05+month06+month07+month08+month09+month10+month11+month12 from months where iduser=".$iduser);
            $fetch=mysql_fetch_array($query);
            $sum_months=$fetch[0];
            $query2=mysql_query("select month_01+month_02+month_03+month_04+month_05+month_06+month_07+month_08+month_09+month_10+month_11+month_12 from months where iduser=".$iduser);
            $fetch2=mysql_fetch_array($query2);
            $sum_months_=$fetch2[0];
            $query3=mysql_query(" update years set ".$year."=".$sum_months." , ".$year2."=".$sum_months_." where iduser=".$iduser);
            }
             
    }
    function query($sql)
    {
        $rs = mysql_query($sql);
      
        return $rs;
    }
    function select($sql)
    {
        $rs = $this->query($sql);
        if (!$rs) {
            return;
        }

        @$num_rows = mysql_numrows($rs);

        if (($rs) && ($num_rows > 0)) {

            $data_array = array();
            while ($row = mysql_fetch_row($rs)) {
                $data_array[] = $row;
            }
            mysql_free_result($rs);

            return $data_array;
        } else {
            return false;
        }
    }
      function is_table($tabname)
    {
        $tabname = trim($tabname);
        if (empty($tabname))
            return false;
        $result = $this->select("SHOW TABLES FROM " . namedb);
        if (is_array($result))
            foreach ($result as $key => $value) {
                if (trim($result[$key][0]) == $tabname) {
                    return true;
                    break;
                }
            }
        return false;
    }
    function is_field($tablename, $field)
    {
        $tablename = trim($tablename);
        $field = trim($field);
        if (empty($tablename) || empty($field))
            return false;
        if (!$this->is_table($tablename))
            return false;
        $result = $this->select("SHOW COLUMNS FROM $tablename");
        if (is_array($result))
            foreach ($result as $key => $value) {
                if (trim($result[$key][0]) == $field) {
                    return true;
                    break;
                }
            }
        return false;
    }
    function checkpass($userid,$password){
       $query=mysql_query("select * from user where id=".$userid." and password='".md5($password)."'");
       $count=mysql_num_rows($query);
       if($count >0){
            return true;
       }else{
            return false;
       }
    }
    function changepassword($userid,$newpassword){
        $query=mysql_query(" update user set password='".md5($newpassword)."' where id=".$userid);
        if($query){
            return true;
        }else{
            return false;
        }
    }
    function is_number($number){
    $pattern = "^[0-9]+$";
    if(eregi($pattern,$number)){
        return true; 
    }else{
        return false; 
    }
}
    function updatedata($userid,$username,$name_site){
        $sql=" update user set username='".$username."' ,  name_site='".$name_site."' where id=".$userid;
        $query=mysql_query($sql);
        if($query){
            return true;
        }else{
            return false;
        }
        
    }
    function statistics($userid){
        $day=date('d');
        for($i=$day;$i>0;$i--){
            if($i=='01'and strlen($i)==2){
               $select.= "day".$i;
               break;
            }
             if($i==1){
               $select.= "day0".$i;
               break;
            }
            if(substr($i,0,1)==0){
                $select.='day'.$i." , ";
            }elseif(strlen($i)==2){
                $select.='day'.$i." , ";
            }else{
                   $select.='day0'.$i." , ";
            }
            
        }
       
        $select_=preg_replace('/day/','day_',$select);
        $query=mysql_query( " select  ".$select.",".$select_." from days where iduser=".$userid) ;
        $fetch=mysql_fetch_array($query);
        $col=array();
        $col[]=$fetch;
        return $col;

    }
        function statistics2($userid){
        $day=date('d');
        for($i=$day;$i>0;$i--){
            if($i==01){
               $select.= "day_0".$i;
               break;
            }
            if(substr($i,0,1)==0){
                $select.='day_'.$i." , ";
            }elseif(strlen($i)==2){
                $select.='day_'.$i." , ";
            }else{
                   $select.='day_0'.$i." , ";
            }
            
        }
       
        $select_=preg_replace('/day/','day_',$select);
        $query=mysql_query( " select  ".$select.",".$select_." from days where iduser=".$userid) ;
        $fetch=mysql_fetch_array($query);
        $col=array();
        $col[]=$fetch;
        return $col;

    }
        function getpointsetting(){
        $sql=mysql_query('select * from points where id=1');
        $fetch=mysql_fetch_array($sql);
        $this->points['point']=$fetch['point'];
        $this->points['minspoint']=$fetch['minspoint'];
        $this->points['invitepoint']=$fetch['invitepoint'];
        $this->points['opener']=$fetch['opener'];
        
    }
}

$user=new user();

?>

up please

See the link, and at least try to fix it. Just compare it with your code, and make changes so it matches the code in the link.

you seem to be new to PHP yet your code is full of advanced stuffs. How can a newbie write such loong and advanced code?

i see the link dear but iam new with php code

can you tell me where i have to add it in line number what ??

or can you add it to me and send it here please

Is that your code or you copied somewhere?

This code programmer from my friend, my friend died accident last month.

i have the Scripts but i get PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

one thing is for sure there is a problem on your query and your post is so ridiculous... its a very long code....

now how can i fix it

please i need help

i will pay if you need, please help me to fix all error

Ok, in all your queries and connect (MySQL functions) add or die(mysql_error()); so that it gives you error at that point and terminates. That is, if the line was

mysql_query("SELECT * FROM dummy_table");

then change it to

mysql_query("SELECT * FROM dummy_table")or die(mysql_error());

then post the error you get (full error) and the line number it complains

ok i add it to all and i get this in error_log

[16-Dec-2010 01:23:58] PHP Fatal error:  Call to a member function username() on a non-object in /home/xxxxxxx/public_html/myads.php on line 24
[16-Dec-2010 01:23:58] PHP Fatal error:  Call to a member function username() on a non-object in /home/xxxxxxx/public_html/myads.php on line 24
[16-Dec-2010 01:23:59] PHP Fatal error:  Call to a member function username() on a non-object in /home/xxxxxxx/public_html/myads.php on line 24
[16-Dec-2010 01:23:59] PHP Fatal error:  Class 'user' not found in /home/xxxxxxx/public_html/admin/functions/admin.php on line 8
[16-Dec-2010 01:23:59] PHP Fatal error:  Call to a member function username() on a non-object in /home/xxxxxxx/public_html/myads.php on line 24
[16-Dec-2010 01:23:59] PHP Warning:  Unexpected character in input:  ''' (ASCII=39) state=1 in /home/xxxxxxx/public_html/classes/user.php on line 47
[16-Dec-2010 01:23:59] PHP Parse error:  syntax error, unexpected $end, expecting ']' in /home/xxxxxxx/public_html/classes/user.php on line 47
[16-Dec-2010 01:24:00] PHP Warning:  Unexpected character in input:  ''' (ASCII=39) state=1 in /home/xxxxxxx/public_html/classes/user.php on line 47
[16-Dec-2010 01:24:00] PHP Parse error:  syntax error, unexpected $end, expecting ']' in /home/xxxxxxx/public_html/classes/user.php on line 47
[16-Dec-2010 01:24:00] PHP Parse error:  syntax error, unexpected $end in /home/xxxxxxx/public_html/classes/user.php on line 95
[16-Dec-2010 01:24:00] PHP Parse error:  syntax error, unexpected $end in /home/xxxxxxx/public_html/classes/user.php on line 237
[16-Dec-2010 01:24:01] PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/classes/user.php on line 162
[16-Dec-2010 01:24:01] PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/classes/user.php on line 62
[16-Dec-2010 01:24:01] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/xxxxxxx/public_html/classes/user.php:162) in /home/xxxxxxx/public_html/myads.php on line 83
[16-Dec-2010 01:24:01] PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/classes/user.php on line 162
[16-Dec-2010 01:24:01] PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/classes/user.php on line 62
[16-Dec-2010 01:24:01] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/xxxxxxx/public_html/classes/user.php:162) in /home/xxxxxxx/public_html/myads.php on line 83
[16-Dec-2010 01:24:02] PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/classes/user.php on line 162
[16-Dec-2010 01:24:02] PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxxxxxx/public_html/classes/user.php on line 62
[16-Dec-2010 01:24:02] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/xxxxxxx/public_html/classes/user.php:162) in /home/xxxxxxx/public_html/myads.php on line 83

please help me Up Up

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.