Post by pablich » Fri Apr 04, 2014 3:56 am

Hi, I'm connecting to the database with this code:

transporte.php

Code: Select all

$dblink = mysql_connect('192.168.x.x', 'opencart', 'opencart') or die( mysql_error() );
mysql_select_db('opencart');
 
$rs = mysql_query('select descripcion from transporte where descripcion like "'. mysql_real_escape_string($_REQUEST['term']) .'%" order by descripcion asc', $dblink);
// loop
$data = array();
if ( $rs && mysql_num_rows($rs) )
{
	while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
	{
		$data[] = array('value' => $row['descripcion']);
	}
}
 
// jQuery wants JSON data
echo json_encode($data);
flush();
but when I try with this code stops working:

Code: Select all

$dblink = mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die('ERROR CONNECTING TO SERVER');
mysql_select_db(DB_DATABASE) or die('ERROR SELECTING TABLE');
$rs = mysql_query('select descripcion from transporte where descripcion like "'. mysql_real_escape_string($_REQUEST['term']) .'%" order by descripcion asc', $dblink);
// loop
$data = array();
if ( $rs && mysql_num_rows($rs) )
{
	while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
	{
		$data[] = array('value' => $row['descripcion']);
	}
}
 
// jQuery wants JSON data
echo json_encode($data);
flush();
Anyone know why?

New member

Posts

Joined
Thu Feb 13, 2014 12:26 am
Who is online

Users browsing this forum: No registered users and 4 guests