SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    ponce
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry My autocomplete script is not working from my server BUT it works locally! :(

    Hi, after i finished this app i got this problem at the very end. I cannot deliver it now until i solve this, its been a whole day working around this.

    Script is online HERE


    thanks!


    autocomplete.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Auto complete demo</title>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    <link type="text/css" rel="stylesheet" href="../admin/themes/redmond.css"  />
    
    <script type="text/javascript">
    
    	$(function() {
    			   
    		$('#buscar_usuario').autocomplete({
    										  
    			source : 'ajax.php',
    			select : function(event, ui)	{
    			
    				$('#resultados').html(
    									  
    					'<h2>Detalles de cliente</h2>' + ui.item.value + '<br/>' + ui.item.tel
    				);
    			}
    		});		   
    			   
    	});
    </script>
    
    </head>
    
    <body>
         
            <div id="busqueda">
              <input type="text" id="buscar_usuario" name="buscar_usuario" />
            </div>
                  <div id="resultados">
                  
                  </div>
              
                    
    </body>
    </html>
    ajax.php
    Code:
    <?
    
    include_once 'clients.class.php';
    
    $usuario = new Usuarios();
    
    echo json_encode($usuario->buscarUsuario($_GET['term']));
    
    ?>
    clients.class.php
    Code:
    <?
    class Usuarios
    {
    
    	public function __construct()	{
    		
    		$dbhost = 'localhost';
    		$dbuser = 'root';
    		$dbpass = '';
    		$dbname = 'expresscomputerdb';
    		
    		mysql_connect($dbhost, $dbuser, $dbpass);
    		
    		mysql_select_db($dbname);
    	}
    	
    	
    	public function buscarUsuario($nombreusuario)	{
    		
    		$datos = array();
    		
    		$sql = "SELECT clientname, phone1, id FROM clients WHERE clientname LIKE '%$nombreusuario%'";
    		$resultado = mysql_query($sql);
    		
    		while ($row = mysql_fetch_array($resultado, MYSQL_ASSOC))	{
    			
    			$datos[] = array("value" => $row['clientname'],
    							 "tel" => $row['phone1'],
    							 "company" => $row['companyname'],
    							  "clientid" => $row['id']
    						);
    		}
    		
    		return $datos;
    	}
    }
    ?>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,688
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    It seems to work for me. Type in "Al" and after a second the list appears.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Dec 2004
    Location
    ponce
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shortly i found the issue after i posted, the knowledge comes by itself when im around you guys!

    I didnt specify the password to the database in clients.class.php


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •