2016-12-05 5 views
-1

この私の問題:エラーCodeIgniterの不足している引数

A PHP Error was encountered

Severity: Warning
Message: Missing argument 1 for TokoSaya::user(), called in /var/www/html/system/core/CodeIgniter.php on line 360 and defined
Filename: controllers/tokosaya.php
Line Number: 32

A PHP Error was encountered

Severity: Notice
Message: Undefined variable: id
Filename: controllers/tokosaya.php
Line Number: 34

A Database Error Occurred

Error Number:
ERROR: syntax error at or near "$" LINE 1: SELECT * FROM usr.persons WHERE id = $id ^
SELECT * FROM usr.persons WHERE id = $id
Filename: /var/www/html/models/m_user.php
Line Number: 18

この私のコントローラ:

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

class TokoSaya extends CI_Controller { 

/** 
* Index Page for this controller. 
* 
* Maps to the following URL 
*  http://example.com/index.php/welcome 
* - or - 
*  http://example.com/index.php/welcome/index 
* - or - 
* Since this controller is set as the default controller in 
* config/routes.php, it's displayed at http://example.com/ 
* 
* So any other public methods not prefixed with an underscore will 
* map to /index.php/welcome/<method_name> 
* @see http://codeigniter.com/user_guide/general/urls.html 
*/ 
function __construct() 
{ 
    parent::__construct(); 
    $this->load->library('form_validation'); 
    $this->load->helper(array('form', 'html', 'file','string')); 
    //$this->load->library('grocery_CRUD'); 
    //$this->load->model('view'); 
    $this->load->model('m_user'); 
    $this->load->model('amproker'); 
    //$this->data['modul'] = 'Admin'; 
} 

function user($id) 
{ 
    $data['user'] = $this->m_user->GetDetailUser($id); 
    //$data['UserLogin'] = $this->m_user->GetUserLogin($data['user']->person) 
    $data['menu'] = $this->amproker->CategoriesMenu(0,$h=""); 
    $data['page'] = 'user'; 
    $this->load->view('templates_user', $data); 
} 

} 

/* End of file welcome.php */ 
/* Location: ./application/controllers/welcome.php */ 

これは私のモデルである:

<?php 

/** 
* 
*/ 
class M_User extends CI_Model 
{ 

function __construct() 
    { 
     // Call the Model constructor 
     parent::__construct(); 
     //$this->load->library(array('My_phpmailer', 'encrypt')); 
    } 

function GetDetailUser($id) 
{ 
    $query=$this->db->query("SELECT t0.*, t1.username, t1.person FROM usr.persons t0 RIGHT JOIN usr.logins t1 ON t0.id = t1.person WHERE t1.person = $id"); 
      return $query->row(); 

} 

//function GetUserLogin($user) 
//{ 
    //$query=$this->db->query("SELECT * FROM usr.logins") 
    //return $query->result(); 
//} 

} 

?> 
+0

...このパラメータは実際に整数であることを確認する必要があり、などの結果を返さない整数(ID)に対処する方法にいくつかの考えを入れたのだろうか? URLにユーザーIDを渡していることを確認してください。 Ex。 'http://localhost/..../tokosaya/user/ {$ id}' – Naga

答えて

0

あなたのエラーの上から作業.. 。

あなたの方法ユーザー($ id)はパラメータを必要としており、明らかにあなたはそれを提供していません。

あなたがこれを書いたやり方では、このパラメータをURLのlocalhost/tokosaya/user/1に入力する必要があります。この場合、この場合1はユーザメソッドの$ idに1の値を与えます。

しかし、あなたはどのようにあなたのコントローラーを呼んだ

関連する問題