Welcome Guest, Not a member yet? Register   Sign In
Cannot use db access after another access in a separate library
#1

[eluser]WebMada[/eluser]
Hello!

I've coded a library as my authentification library
Code:
public function Login($argLogin, $argPassword) {
  
  $this->CI =& get_instance();

$sqlUtilisateurs = "SELECT "
       . CURRENTUSER_USER_IDCOL . ", "
       . CURRENTUSER_USER_LOGINCOL . ", "
       . CURRENTUSER_USER_PASSWORDCOL
      . " FROM " . CURRENTUSER_USER_TABLENAME
      . " WHERE "
       . CURRENTUSER_USER_LOGINCOL . " = '" . $this->CI->db->escape_str($argLogin) . "' AND "
       . CURRENTUSER_USER_PASSWORDCOL . " = '" . $this->CI->db->escape_str($argPassword) . "' ";

$qryUtilisateurs = $this->CI->db->query($sqlUtilisateurs)->result();
The problem is: when I query db after a call of this Login() function, I got the following errors:
Quote:Severity: Warning
Message: mysql_errno(): 44 is not a valid MySQL-Link resource
Filename: mysql/mysql_driver.php
Line Number: 453

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /homez.68/siteyard/www/demo/MyWebSite/system/core/Exceptions.php:170)
Filename: core/Common.php
Line Number: 409
According to me, the error is a conflict between $this->CI =& get_instance() launched in Login() and the instance in the controller using it.

Another fact is this problem is just on my hoster but it works correctly locally with Xamp, Wampserver, etc.

Code:
$GLOBALS["gUser"]->Login($this->input->post("txtLogin"), $this->input->post("txtMotDePasse"));
if ($GLOBALS["gUser"]->IsConnected()) {
$this->load->model("user");
$this->user->GetUsers(1);
The error appears when executing the line "$this->user->GetUsers(1)" because there is an access of the DB inside.

Regards,

webmada




Theme © iAndrew 2016 - Forum software by © MyBB