CodeIgniter Forums
Database LiveSearch - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database LiveSearch (/showthread.php?tid=52125)

Pages: 1 2 3 4


Database LiveSearch - El Forum - 05-30-2012

[eluser]sanir[/eluser]
Code:
function getSearchResults(value) {
   $.post("http://localhost/crm/index.php/search/getSearchResults",{partialSearch:value}, function(data){
    $("#search_results").html(data);
   });
  }

try this code.


Database LiveSearch - El Forum - 05-30-2012

[eluser]joe.afusco[/eluser]
Still internal server error.


Database LiveSearch - El Forum - 05-30-2012

[eluser]sanir[/eluser]
open this url in browser then tell me what happen.

http://localhost/crm/index.php/search/getSearchResults


Database LiveSearch - El Forum - 05-30-2012

[eluser]joe.afusco[/eluser]
I receive the following error:


( ! ) Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\crm\application\controllers\search.php on line 17

line 17 refers to the db query

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

class Search extends CI_Controller {


public function index()
{
  
}

public function getSearchResults()
{
  $this->load->database();  
  $partialSearch = $_POST['partialSearch'];
  $query = $this->db->select('email_address')
  ->like('email_address', $partialSearch);
  ->get('users');
  
  $result = $query->result();
  $data = "";
  foreach($result as $row){
     $data = $data . "<div>" . $row->email_address . "</div>";
  }
  echo $data;
}
}




Database LiveSearch - El Forum - 05-30-2012

[eluser]sanir[/eluser]
Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends CI_Controller {


public function index()
{
  
}

public function getSearchResults()
{
  $this->load->database();  
  $partialSearch = $_POST['partialSearch'];
  $query = $this->db->select('email_address');
  ->like('email_address', $partialSearch);
  ->get('users');
  
  $result = $query->result();
  $data = "";
  foreach($result as $row){
     $data = $data . "<div>" . $row->email_address . "</div>";
  }
  echo $data;
}
}

try this code


Database LiveSearch - El Forum - 05-30-2012

[eluser]joe.afusco[/eluser]
Internal server error.

parse error still the same, except line 16.

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\crm\application\controllers\search.php on line 16


Database LiveSearch - El Forum - 05-30-2012

[eluser]sanir[/eluser]
http://localhost/crm/index.php/search/getSearchResults

use this url and give me complete errror.


Database LiveSearch - El Forum - 05-30-2012

[eluser]joe.afusco[/eluser]
Complete error:

( ! ) Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\wamp\www\crm\application\controllers\search.php on line 16
Call Stack
# Time Memory Function Location
1 0.0006 700368 {main}( ) ..\index.php:0
2 0.0018 793176 require_once( 'C:\wamp\www\crm\system\core\CodeIgniter.php' ) ..\index.php:202


Database LiveSearch - El Forum - 05-30-2012

[eluser]sanir[/eluser]
Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Search extends CI_Controller {


public function index()
{
  
}

public function getSearchResults()
{
  $this->load->database();  
  $partialSearch = $_POST['partialSearch'];
  $this->db->select('email_address');
  $this->db->like('email_address', $partialSearch);
  $query = $this->db->get('users');
  
  $result = $query->result();
  $data = "";
  foreach($result as $row){
     $data = $data . "<div>" . $row->email_address . "</div>";
  }
  echo $data;
}
}

try this code


Database LiveSearch - El Forum - 05-30-2012

[eluser]joe.afusco[/eluser]
Internal server error.

A PHP Error was encountered

Severity: Notice

Message: Undefined index: partialSearch

Filename: controllers/search.php

Line Number: 14