Welcome Guest, Not a member yet? Register   Sign In
I don't understand what I'm doing wrong...
#1

[eluser]Unknown[/eluser]
I have this code that will affect one field in a database, however its not working for some reason and I don't see my error, please, I need help:

controller

Code:
class noticias extends CI_controller
{
public function __construct()
{
  parent::__construct();
  $this->load->model('noticia_model');
  $this->load->helper('url');
  $this->load->library('session');
}

public function deactivatenoticia()
{
  $id=$_GET['id'];
  $ini=$_GET['fechaini'];
  $fin=$_GET['fechafin'];
  if($this->session->userdata('user_level') != null)
  {
   $this->noticia_model->ocultarNoticia($id);
   $str = '/noticias/search?fechaini='.$ini.'&fechafin;='.$fin;
   echo $str;
   redirect('/noticias/search');
  }
  else
  {
   redirect('/loginc/initlogin/');
  }
}
}

and the method in the model is:
Code:
function ocultarNoticia($id)
   {
   $this->load->database();
    $query=$this->db->query("Update noticias set not_visible=1 where id_noticia = $id");
   }

the proble is that the application is not responding, since I also tried commenting the if, and it still doesn't do the code inside, as if I had never written the code (I even tried to enter sintax error in the model and it didn't recognize it).
#2

[eluser]rad11[/eluser]
Did u used a var_dump ?
#3

[eluser]InsiteFX[/eluser]
For one all MySQL query names are all upper case UPDATE SET WHERE get the picture?
#4

[eluser]Tpojka[/eluser]
Class name should be capitalized too.
#5

[eluser]Unknown[/eluser]
Code:
echo $str;
redirect('/noticias/search');

You can't use echo with redirect. Redirect send header http to browser, and it don't want anything sent before :-)




Theme © iAndrew 2016 - Forum software by © MyBB