System error after it went up to server

Asked

Viewed 64 times

1

The system was developed in php using the codeigniter 3 framework.

Works great on localhost.

I went up to the server and started giving problems. I checked php installed and is in version 5.6

Mistakes that happen:

Message: Object of class Ci_db_mysqli_result could not be converted to int

Filename: models/Users.php

Line Number: 12

Message: Cannot Modify header information - headers already sent by (output Started at /home/user145/public_html/sistema/system/core/Exceptions.php:271)

Filename: helpers/url_helper.php

Line Number: 564

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Usuarios_model extends CI_Model {

public function login($username, $password) {
    $this->db->where("username", $username);
    $this->db->where("password", $password);

    $resultados = $this->db->get("usuarios");

    if ($resultados > 0) { ----------------------> LINHA 12
        return $resultados->row();
    }
    else {
        return false;
    }
}}

When I return to some page this error happens:

Severity: Warning

Message: unlink(/tmp/ci_session9c9ddb88511925d48aa2df5fd44857177296879f): Operation not permitted

Filename: drivers/Session_files_driver.php

Line Number: 384

Backtrace:

File: >/home/user145/public_html/sistema/application/controllers/Dashboard.php Line: 7 Function: __Construct

File: /home/user145/public_html/sistema/index.php Line: 315 Function: require_once

After going up the server, some pages are not being found when I try to access.

  • Place the error location, the reference codes!

  • first error any $query of yours that is returning an int that cannot be solved.

  • Okay, I’ll edit the question

  • if ($resultados) { ..... already so resolves!

  • Thanks. but that’s not normal... on the fucnion localhost and up the server, it doesn’t work

  • 1

    @user102074 it is difficult to say if really in localhost is working properly, because, we have no way to test, now I indicated the wrong code that you are doing, because, there does not return an entire, there can return null or a objeto so I said take it off >0! then you are programming wrong, don’t take me so bad ... it is an indication that we need to study a little more.

  • The bug has been fixed, but because now my ajax doesn’t work? can’t find any page? it’s as if the links are obsolete

  • 1

    @user102074 ai is another context, for sure your code has other problems!

  • my views are not being found

  • @user102074 weird even then has more coding problems.

  • Operation not permitted Probably your PHP you are not allowed to write/remove this session file. Check permissions. Is there an error when you try to access your views? You are using the same configs (Apache/Nginx, PHP etc) as the localhost on the server??

  • When I try to access the views, error 404 occurs in the browser network. Views are on the server.

Show 7 more comments

1 answer

0

As the comments pointed out above, perhaps it lacks some experience in programming. On line 12 you are checking if the query returned any data. To do this it is not necessary to make $results > 0`, since in php everything is considered true except

  1. 0 (zero in number)
  2. "0" (zero string)
  3. false
  4. "" (empty string)
  5. null
  6. array() (empty array)

If you want to study a little more about it I suggest the documentation of the PHP

Therefore, to make this comparison just do

if ($resultados)

Review all your code to make sure it’s not happening elsewhere.

  • I appreciate the help. but the problem now is another

  • I posted the other errors that happen. My views are not being found. I am using base_url() links and changed the file config.php.

  • what value you put to your base url?

  • I put the link where is the example system: http://meusite.com.br/sistema/... just like that

  • on your server, you have placed your entire system inside a folder called system? pq otherwise you do not need that part. It would be much easier to find the errors if you posted the link from your site. This is possible?

  • That, inside a folder.. Why is that a bad practice? I can’t put in the root... at the root has a website.

  • It can be like this, no problem. Try to see what is happening in the network tab of your browser

  • the fact that it is in a folder prevents my views from being found?

  • No. I’ve climbed systems that were in subfolders of the system and everything worked normally. No more information (code) will help you find the problem.

  • When I try to access the views, error 404 occurs in the browser network. Views are on the server.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.