php - fatal error: Destructor cannot take arguments -


i'am newbie in programming... try call webservice android. have fatal error there.

1.this android coding

public class userfunction {     private jsonparser jsonparser;      private static string loginurl="http://10.0.2.2/android/include/index.php";     private static string registerurl="http://10.0.2.2/android/include/index.php";      private static string login_tag="login";     private static string register_tag="register";       public userfunction(){         jsonparser=new jsonparser();     }       public jsonobject loginuser(string email, string password){         //building parameter         list<namevaluepair> params= new arraylist<namevaluepair>();         params.add(new basicnamevaluepair("tag", login_tag));         params.add(new basicnamevaluepair("email", email));         params.add(new basicnamevaluepair("password", password));         jsonobject json=jsonparser.getjsonfromurl(loginurl, params);          return json;     }       public jsonobject registeruser(string email, string name, string password){         //building parameter         list<namevaluepair> params= new arraylist<namevaluepair>();         params.add(new basicnamevaluepair("tag", login_tag));         params.add(new basicnamevaluepair("name", name));         params.add(new basicnamevaluepair("email", email));         params.add(new basicnamevaluepair("password", password));         //getting jsonobject         jsonobject json=jsonparser.getjsonfromurl(registerurl, params);          return json;     }       public boolean isuserloggedin(context context){         databasehandler db= new databasehandler(context);         int count=db.getrowcount();         if(count>0){             return true;         }         return false;     }       public boolean logoutuser(context context){         databasehandler db=new databasehandler(context);         db.resettable();         return false;        } } 

2.this index.php

if(isset($_post['tag'])&& $_post['tag'] !=''){         //get tag         $tag=$_post['tag'];          //include db handler         require_once ('db_functions.php');//ganti include         $db=new db_functions();          //response array         $response=array ("tag"=> $tag, "success"=>0, "error"=>0);          //check 4 tag type         if($tag='login'){             //req type check login             $email=$_post['email'];             $password=$_post['password'];              //check 4 user             $user=$db->getuserbyemailandpassword($email, $password);             if($user !=false){                 /* user found                 * echo json success =1 */                 $response ["success"]=1;                 $response["uid"]=$user["unique_id"];                 $response ["user"]["name"]=$user["name"];                 $response["user"]["email"]=$user["email"];                 $response ["user"]["created_at"]=$user["created_at"];                 $response["user"]["updated_at"]=$user["updated_at"];                 echo json_encode($response);             }             else{                 /* user not found                 * echo json error =1 */                 $response ["error"]=1;                 $response["error_msg"]="incorrect email or password!!!";                 echo json_encode($response);             }         }         else if($tag=='register'){             //req type register new user             $name=$_post['name'];             $email=$_post['email'];             $password=$_post['password'];              //check if user existed             if($db->isuserexisted($email)){                 //user existed - error response                 $response["error"]=2;                 $response["error_msg"]="user exists";                 echo json_encode($response);             }             else{                 //store user                 $user=$db->storeuser($name, $email, $password);                 if($user){                     //user stored successfull                     $response ["success"]=1;                     $response["uid"]=$user["unique_id"];                     $response ["user"]["name"]=$user["name"];                     $response["user"]["email"]=$user["email"];                     $response ["user"]["created_at"]=$user["created_at"];                     $response["user"]["updated_at"]=$user["updated_at"];                     echo json_encode($response);                 }                 else{                     //user failed store                     $response ["error"]=1;                     $response["error_msg"]="error occured in registration";                     echo json_encode($response);                 }             }         }         else{             echo "invalid request";         }     }     else{         echo "access denied";     } ?> 

3. db_functions.php

<?php     class db_functions{         private $db;         /*constructor*/         function __construct($db){             require_once ('db_connect.php');//ganti include             /*connecting db*/             $this->db= new db_connect();             $this->db->connect();         }         /*destructor*/         function __destruct($db){         }          /*         *storing new user         *returning user detail         */          public function storeuser($name, $email, $password){             $uuid= uniqid('',true);             $hash= $this->hashssha($password);             $encrypted_password= $hash["encrypted"]; //encripted password             $salt=$hash["salt"];//salt             $result=mysql_query("insert account_users(unique_id, name, email, encrypted_password, salt, created_at) values ('$uuid','$name','$email','$encrypted_password','$salt',now())");             /*check succesfull store*/             if($result){                 /*get user detail*/                 $uid= mysql_insert_id();                 $result= mysql_query("select * account_users uid='$uid'");                 /*return user detail*/                 return mysql_fetch_array($result);             }             else{                 return false;             }         }         /*         *get user email & password         */          public function getuserbyemailandpassword($email, $password){             $result=mysql_query("select * account_users email='$email'") or die (mysql_error());             //check 4 result             $no_of_rows=mysql_num_rows($result);             if($no_of_rows>0){                 $result=mysql_fetch_array($result);                 $salt=$result['salt'];                 $encrypted_password=$result['encrypted_password'];                 $hash=$this->checkhashssha($salt, $password);                 //check pass equality                 if($encrypted_password==$hash){                     //user auth correct                     return $result;                 }             }             else{                 //user not found                 return false;             }         }          /*         *check user existed or not         */         public function isuserexisted($email){             $result=mysql_query("select email account_users email='$email'");             $no_of_rows=mysql_num_rows($result);             if($no_of_rows>0){                 //user existed                 return true;             }             else{                 //user not existed                 return false;             }         }         /*         *encrypting pass         *@param pass         *return salt & encrpted pass         */         public function hashshha($password){             $salt=sha1(rand());             $salt=substr($salt, 0, 10);             $encrypted= base64_encode(sha1($password.$salt, true).$salt);             $hash=array("salt"=> $salt, "encrypted"=> $encrypted);             return $hash();         }         /*         *decrypting pass         *@param salt, pass         *return hash string         */         public function checkhashssha($salt, $password){             $hash=base64_encode(sha1($password.$salt, true).$salt);             return $hash;         }      } ?> 

4. , last error when run android code

07-18 02:07:59.393: d/dalvikvm(541): gc_explicit freed 3420 objects / 314064 bytes in 340ms 07-18 02:08:08.802: e/json(541): <br />n<b>fatal error</b>:  destructor db_functions::__destruct() cannot take arguments in <b>c:\xampp\htdocs\android\include\db_functions.php</b> on line <b>13</b><br />n 07-18 02:08:08.802: e/json parser(541): error parsing dataorg.json.jsonexception: value <br of type java.lang.string cannot converted jsonobject 07-18 02:08:08.802: w/system.err(541): java.lang.nullpointerexception 07-18 02:08:08.812: w/system.err(541):  @ com.androidta.androidclient.registeractivity$1.onclick(registeractivity.java:58) 07-18 02:08:08.812: w/system.err(541):  @ android.view.view.performclick(view.java:2408) 07-18 02:08:08.812: w/system.err(541):  @ android.view.view$performclick.run(view.java:8816) 07-18 02:08:08.812: w/system.err(541):  @ android.os.handler.handlecallback(handler.java:587) 07-18 02:08:08.812: w/system.err(541):  @ android.os.handler.dispatchmessage(handler.java:92) 07-18 02:08:08.812: w/system.err(541):  @ android.os.looper.loop(looper.java:123) 07-18 02:08:08.812: w/system.err(541):  @ android.app.activitythread.main(activitythread.java:4627) 07-18 02:08:08.822: w/system.err(541):  @ java.lang.reflect.method.invokenative(native method) 07-18 02:08:08.858: w/system.err(541):  @ java.lang.reflect.method.invoke(method.java:521) 07-18 02:08:08.858: w/system.err(541):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:868) 07-18 02:08:08.858: w/system.err(541):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:626) 07-18 02:08:08.862: w/system.err(541):  @ dalvik.system.nativestart.main(native method) 

i've problem destruct function..., please me solve this..., big solution,,, :)

just remove $db parameter destructor. should this.

/*destructor*/ function __destruct(){ } 

if need access database destructor, can use $this->db since you've initialised in constructor.

in addition that, should remove $db parameter constructor well. it's not being used, , don't pass arguments when construct db_functions object in index.php.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -