SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    insert into table problem?

    Hey guys! So i'm trying to log information from a form into the database, but it's not working for some reason. I've been looking over this code for too long, can someone else spot the error?

    PHP Code:
     public function log_client(){
            if(
    $this->is_valid() == true){

                
    $log_client_query ='insert into client values("0","'.$this->name.'","'.$this->sex.'","'.$this->age.'","'.$this->doctor.'");';
                
    $log_client $this->link->query($log_client_query);

                if(
    $log_client){

                    if(
    $this->log_info() == true){
                        echo 
    "success";
                        if(
    $this->send_email() == true){
                            echo 
    "successful";
                        }else{
                            echo 
    "failure";
                        }
                    }else{
                        echo 
    "failure";
                    }

                }else{
                    echo 
    "An Insert Error Has Occurred";
                }
            }else{
                
    $this->show_errors();
            } 
    I'm passing the is_valid() check, but not the insert into database check. Any suggestions?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Do you get an error?

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no errors except the ones i create with the if statements

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Can you show us the declaration for $this->link? If it is a class, can you post the class?

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the link is a private variable that's initialized in the __contruct. it looks like this:
    PHP Code:
    class process{
        private 
    $link;
        private 
    $name;
        private 
    $age;
        private 
    $sex;
        private 
    $doctor;
        private 
    $errors;

        public function 
    __construct(){
        
    $this->age $this->validate(intval($_POST['age']));
        
    $this->name $this->validate($_POST['name']);
        
    $this->doctor $this->validate($_POST['doctor']);
        
    $this->sex $_POST['sex'];
        
    $this->errors = array();
        
    $this->link = new mysqli(host','user','password','db');
        } 

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,136
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Try outputting $this->link->error, see if that gives any additional details.


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
  •