Welcome Guest, Not a member yet? Register   Sign In
Database troubles
#1

[eluser]stuffradio[/eluser]
For some reason it works on my localhost, but not on this live server. Do you see anything wrong with this script?

This is what gets called when the form is posted

Code:
function register()
    {
        $this->registerlib->username = $this->input->post('username', TRUE);
        $this->registerlib->password = $this->input->post('password', TRUE);
        $this->registerlib->email = $this->input->post('email', TRUE);
        $this->registerlib->user_ip = $this->input->post('user_ip', TRUE);
        
        $this->registerlib->signup();        
    }

This is the registerlib file

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Registerlib
{
    var $username;
    var $password;
    var $email;
    var $user_ip;

  function Registerlib()
  {
    $this->CI =& get_instance();
    $this->CI->load->library(array('validation'));
  }

  function checkaccount()
  {
    if (strlen($this->username) < 1)
    {
      $data['error_message'] = 'Your username must be at least 1 characters in length!';
    $this->CI->load->view('header');
      $this->CI->load->view('home', $data);
    $this->CI->load->view('footer');
    } else {
    $rows = $this->CI->db->get_where('users', array('username' => $this->username));
    $count = $rows->num_rows();
    if ($count > 0)
    {
    $data['error_message'] = 'An account with this username already exists!';
    $this->CI->load->view('header');
      $this->CI->load->view('home', $data);
    $this->CI->load->view('footer');
      return false;
    } else {
      return true;
    }
    
    }
  }


  function signup()
  {
    $rules['username'] = "required";
    $rules['password'] = "required";
    $rules['email'] = "required";

    $this->CI->validation->set_rules($rules);

    $fields['username'] = 'Username';
    $fields['password'] = 'Password';
    $fields['email'] = 'Email Address';

    $this->CI->validation->set_fields($fields);
    if ($this->checkaccount())
    {

    if ($this->CI->validation->run() == false)
    {
      $data['error_message'] = $this->validation->error_string;
    $this->CI->load->view('header');
      $this->CI->load->view('home', $data);
    $this->CI->load->view('footer');
    } else {

      $data = array(
              'username' => $this->username,
              'password' => md5($this->password),
              'email' => $this->email,
              'date' => date("m/d/Y"),
              'user_ip' => $this->user_ip
              );
    
      $this->CI->db->set($data);
      $this->CI->db->insert('users');
    $data['success_message'] = 'You have successfully registered an account!';
    $this->CI->load->view('header');
      $this->CI->load->view('home', $data);
    $this->CI->load->view('footer');
    }
    }
  }
  
}

I don't see anything wrong with it. I know the username/pass for the database is right because I just created a new one and still nothing gets executed.
#2

[eluser]slowgary[/eluser]
Are you getting an error message or anything? Also, you should enable profiling and check the queries, maybe even paste them into phpmyadmin and see if they run.
#3

[eluser]stuffradio[/eluser]
I ran profiling and the queries aren't even being executed. No errors as well.
#4

[eluser]stuffradio[/eluser]
Tried it on one of my servers and it works... but not on my clients server. What kind of things would make it not compatible? He has PHP 5 and MySQL 5...
#5

[eluser]slowgary[/eluser]
What about yours? Same? Lots of things vary between servers, .htaccess for one. Are they running Linus or Bill? Are you sure the database is the same? Database password? Database config settings? Did you ask your client's server 'pretty please'?
#6

[eluser]stuffradio[/eluser]
My server on localhost was latest PHP 5 and MySQL, server one is PHP 5 and MySQL the latest. htaccess is the same on all machines. They're running Linux. Database structure etc. is the same, correct user/pass.

Edit: No the MySQL and PHP is one version down from the latest build. That shouldn't make that much of a difference though as on my local machine it's an older build.

It simply doesn't execute any MySQL queries.
#7

[eluser]slowgary[/eluser]
Are you sure your client's server is configured correctly? Check the server log for errors.

Or try a simple PHP script that justs connects to the database, issues a select statement, and echo's the result. Then at least you'll know if the database connection is working.
#8

[eluser]stuffradio[/eluser]
Okay I tested with a simply query and it worked... so I'm still lost what could be wrong.

His server:
Quote:Apache version 2.2.9 (Unix)
PHP version 5.2.6
MySQL version 5.0.77-community
Architecture i686
Operating system Linux
Kernel version 2.6.18-53.el5

Current server:
Quote:Apache version 2.0.63
PHP version 5.2.5
MySQL version 5.0.67-community
Architecture i686
Kernel version 2.6.18-92.1.10.el5
#9

[eluser]slowgary[/eluser]
Aha! I have NO ideaSmile. Someone smart will come along and help though, they always do. I never even used a computer before.
#10

[eluser]stuffradio[/eluser]
It's my first day on this thing called, "The Internet" Smile




Theme © iAndrew 2016 - Forum software by © MyBB