Welcome Guest, Not a member yet? Register   Sign In
MS SQL does not work
#1

[eluser]=G-Man=[/eluser]
Hello, I just started playing with CodeIgniter and am converting an older Full PHP site over to it. But I'm having a huge issue with MSSQL, as soon as i call $this->load->database() the page just stops loading and I get a plank page, No errors from codeigniter, or in the PHP error log. I saw a few posts about this and they all seemed to be upgrading to 1.6.2 so I tried a few earlier versions (1.4.1, 1.5.3, 1.6.0) and thay all do the same thing as soon as I try to load the database functions.

here is my database.php

Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "sql1";
$db['default']['username'] = "sa";
$db['default']['password'] = "<password>";
$db['default']['database'] = "lin2admin";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

<password> being a mask for the forum.

I know the DB server is running, because I can connect to it via the MS SQL Management Studio. There is also no firewall on the SQL server itself and the WEB server is on the same local network as the SQL server and my Development computer that I can connect to the DB server with the management studio.

Thanks for your help.
-Don
#2

[eluser]Michael Wales[/eluser]
Could you paste the code from your Controller - usually a blank screen means there is a syntax error.

Also, you could turn off output compression and set error_reporting to E_ALL in config.php - that should allow you to see PHP's syntax errors.
#3

[eluser]=G-Man=[/eluser]
Wow, thanks for the fast response!

Well i don't have output compression enabled and error reporting is set to error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT

I did enable the internal logging for codeigniter and have this

Code:
DEBUG - 2008-06-08 02:33:08 --&gt; Config Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Hooks Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; URI Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Router Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Output Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Input Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2008-06-08 02:33:08 --&gt; Language Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Loader Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Controller Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Helpers loaded: url, form
DEBUG - 2008-06-08 02:33:08 --&gt; Session Class Initialized
DEBUG - 2008-06-08 02:33:08 --&gt; Database Driver Class Initialized

Heres my controller
Code:
&lt;?
class Login extends Controller {    
    function Login()
    {
        parent::Controller();
        $this->load->helper(array('url','form'));
        $this->load->library('simplelogin');
        $this->load->library('session');
        $this->load->database();
    }
    
    //
    // Displays the login form.
    //
    function index()
    {
        $this->load->view('login_view');
    }
    
    function check()
    {
        //Load
        $this->load->library('validation');
        
        //Check incoming variables
        $rules['username']    = "required|min_length[4]|max_length[32]|alpha";
        $rules['password']    = "required|min_length[4]|max_length[32]|alpha";        

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

        $fields['username'] = 'Username';
        $fields['password'] = 'Password';
        
        $this->validation->set_fields($fields);
                
        if ($this->validation->run() == false) {
            $this->session->set_flashdata("LoginResult", "Login Failed");
            redirect('/login');
        }
        else
        {
            $loginResult = $this->simplelogin->login($this->input->post('username'), $this->input->post('password'));
            if($loginResult == true)
            {
                redirect('/l2admin');
            }
            else
            {
                $this->session->set_flashdata("LoginResult", "Login Failed");
                redirect('/login');    
            }
        }
    }
}
?&gt;

I can comment out the Simplelogin call and still get teh issue, so its not in there. also the URL stays at /login/check so it's not even getting that far.
#4

[eluser]Michael Wales[/eluser]
Odd... it's not even getting the Validation library loaded, so it's the database call within you constructor.

Try turning off pconnect in database.php, if that doesn't work, try this:

Remove the database call from constructor.
Add the following to check():
Code:
function check() {
  log_message('debug', 'Entered check method...');
  $this->load->database();
  $this->load->validation();
  // ... rest of method ...
}

Check the log file for the entering check method line.

This will allow us to confirm it is the call to the database and not some issue with your routing.
#5

[eluser]=G-Man=[/eluser]
Well changing the pconnect to false did't change anything

I changed the check method begining to your suggestion and still nothing

Code:
DEBUG - 2008-06-08 02:53:18 --&gt; Config Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Hooks Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; URI Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Router Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Output Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Input Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2008-06-08 02:53:18 --&gt; Language Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Loader Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Controller Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; Helpers loaded: url, form
DEBUG - 2008-06-08 02:53:18 --&gt; Session Class Initialized
DEBUG - 2008-06-08 02:53:18 --&gt; File loaded: C:\htdocs\dlgnetworks\www/system/application/views/login_view.php
DEBUG - 2008-06-08 02:53:18 --&gt; Final output sent to browser
DEBUG - 2008-06-08 02:53:18 --&gt; Total execution time: 0.0547
DEBUG - 2008-06-08 02:53:28 --&gt; Config Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Hooks Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; URI Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Router Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Output Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Input Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2008-06-08 02:53:28 --&gt; Language Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Loader Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Controller Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Helpers loaded: url, form
DEBUG - 2008-06-08 02:53:28 --&gt; Session Class Initialized
DEBUG - 2008-06-08 02:53:28 --&gt; Entered check method...
DEBUG - 2008-06-08 02:53:28 --&gt; Database Driver Class Initialized

Still stoping after it loads the database driver.
#6

[eluser]Michael Wales[/eluser]
Create a new PHP file with the following code:

Code:
&lt;?php

mssql_connect('sql1', 'sa', '<password>') or die('Could not connect to database.');
mssql_select_db('lin2admin') or die('Could not select database.');
$r = mssql_query('SELECT SERVERPROPERTY(\'productversion\') AS version');

while ($line = mssql_fetch_row($r)) {
  print $line[0] . ', ' . $line[1];
}

?&gt;

Let's make sure PHP can connect to MSSQL before blaming CI.
#7

[eluser]=G-Man=[/eluser]
Ok, Think that solved the problem. Somehow MSSQL got disabled on that web server. But the strange thing is that PHP actually gave the error about calling an undefined function mssql_connect(). so might need to be a added feature in later versions of codeigniter so people have some kind of direction.

Thanks for your help.
#8

[eluser]Michael Wales[/eluser]
I think that is outside the scope of CI - been awhile since I worked with a MSSQL server but I am fairly certain it's a php.ini setting.
#9

[eluser]chris_rey[/eluser]
[quote author="Michael Wales" date="1212922017"]I think that is outside the scope of CI - been awhile since I worked with a MSSQL server but I am fairly certain it's a php.ini setting.[/quote]

Hi Michael, may i ask how am going to configure my php.ini so that i can connect to the database? i'm also having the same problem.




Theme © iAndrew 2016 - Forum software by © MyBB