Results 1 to 4 of 4
  1. #1

    Default Help with PHP code problem


    <?php
    class myController{
    private $host="localhost", $user="root", $pass="", $db="animeshop";
    public $con, $db_select;
    public $user_name, $user_pass, $user_fname, $user_lname, $user_mname, $user_add, $queried;

    public function connect(){
    $this->con = mysql_connect($this->host, $this->user, $this->pass);
    $this->db_select = mysql_select_db($this->db, $this->con);
    }
    public function query($result){
    return mysql_query($result, $this->con);
    }
    public function destruct(){
    return mysql_close($this->con);
    }
    }

    class member extends myController{
    public $user_name, $user_pass, $user_fname, $user_lname, $user_mname, $user_add, $queried;
    public $user_log, $pass_log, $result;
    public function __construct($fname, $lname, $mname, $add, $password, $username){

    $this->user_name = $username;
    $this->user_pass = $password;
    $this->user_fname = $fname;
    $this->user_lname = $lname;
    $this->user_mname = $mname;
    $this->user_add = $add;

    $this->queried = "INSERT INTO customer_account(customer_name, customer_last_name, customer_mid_name, customer_address, username, password) values('$this->user_fname', '$this->user_lname', '$this->user_mname', '$this->user_add', '$this->user_name', '$this->user_pass')";
    }
    public function get_query(){
    $this->query($this->queried);
    }
    public function set_login($acc_user, $acc_pass){
    $this->user_log = $acc_user;
    $this->pass_log = $acc_pass;

    $this->select_query = "SELECT * FROM customer_account where username = '$this->user_log' && password = '$this->pass_log'";
    }
    public function get_login(){
    $this->result = $this->query($this->select_query);
    }
    }
    ?>

    my problem is nag expect 2 ug parameters ang mysql_query nako which is ang 2nd parameter jud nga naka declare naman cya daan nya public pajud para ma reuse sa sakong member nga class...pero ako gi check ok man tanan. if akong in apil ang $this->connect() before sa $this->query() inside sa kong member class working cya, pero di man cguro advisable nga mga cge kog establish ug connection sakong db everytime nga mo query ko kay naka establish nman cya sakong myController.

    can anyone help me with this problem?

    i'm still practicing OOP para pangandam sa php frameworks...still preferred hardcode gihapon
    Last edited by senpai91; 11-13-2012 at 07:39 AM.

  2. #2

    Default Re: Help with PHP code problem

    try this:
    public function query($result){
    if(!isset(this->con)){$this->connect();}
    return mysql_query($result, $this->con);
    }

  3. #3

    Default Re: Help with PHP code problem

    also saimong destruct e remove na ang return..dayon e restructure imong class Bro

  4. #4

    Default Re: Help with PHP code problem

    wrong section adto sa programming...

  5.    Advertisement

Similar Threads

 
  1. I need help with a certain problem with my PC
    By PGM_301 in forum Computer Hardware
    Replies: 14
    Last Post: 01-15-2009, 05:37 AM
  2. Help with PHP Login Stuff
    By poymode in forum Programming
    Replies: 36
    Last Post: 06-20-2008, 07:57 AM
  3. need help with lap top problem
    By earthwindfire in forum Computer Hardware
    Replies: 4
    Last Post: 03-10-2007, 03:39 PM
  4. NEED HELP WITH THIS CODE
    By saminoske in forum Websites & Multimedia
    Replies: 1
    Last Post: 12-05-2005, 11:27 AM
  5. help with security code!!!! PLEASE!
    By blue_orange in forum Gizmos & Gadgets (Old)
    Replies: 7
    Last Post: 11-29-2005, 08:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top