2011-11-22 84 views
3

我試圖用codeigniter創建一個xml響應。當我運行代碼時,會引發以下錯誤。PHP Codeigniter錯誤:調用未定義的方法ci_db_mysql_driver :: result()

此頁面包含以下錯誤:

1號線誤差在列48:在文檔的末尾附加內容

<?php 
class Api extends CI_Controller{ 

    function index() 
    { 
     $this->load->helper('url', 'xml', 'security'); 
     echo '<em>oops! no parameters selected.</em>'; 

    } 

    function authorize($email = 'blank', $password = 'blank') 
    { 
     header ("content-type: text/xml"); 
     echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; 
     echo '<node>'; 

     if ($email == 'blank' AND $password == 'blank') 
     { 
       echo '<response>failed</response>'; 
     } 
     else 
     { 
      $this->db->where('email_id', $email); 
      $this->db->limit(1); 
      $query = $this->db->from('lp_user_master'); 
      $this->get(); 
      $count = $this->db->count_all_results(); 

      if ($count > 0) 
      { 
       foreach ($query->result() as $row){ 
        echo '<ip>'.$row->title.'</ip>'; 
       } 
      } 
     } 
     echo '</node>'; 
    } 
} 
?> 
+0

你也可以說是正在分析的最終結果? –

回答

9

這裏你的代碼是錯誤的:

$this->db->where('email_id', $email); 
$this->db->limit(1); 
$query = $this->db->from('lp_user_master'); 
$this->get(); 

應改爲:

$this->db->where('email_id', $email); 
$this->db->from('lp_user_master'); 
$this->db->limit(1); 
$query = $this->db->get(); 

現在,您可以撥打$query->result(),因爲結果是資源後有你實際得到的結果見表

相關問題