Hi all,
Developing a small time tracking application, I've been using comboboxes for too much things... I've just learned UI can use jquery to process text inputs with autocomplete...
That way everything is easier when you have plenty of data to filter.
This said, following samples in the Internet I've got it working fine... I have a text input that offers options to choose from once you start writing.
I have an auxiliar database interface file (database.php) where I have all the database functions, even the connect to database small script (getConn() that returns the pointer to the database connection).
In the main PHP file I have:
<script>
$(function()
{
$("#edCustomer").autocomplete(
{
source: "autoCustomer.php"
});
});
</script>
And in autoCustomer.php:
<?php
include('127.0.0.1/rt/database.php'
$DB = getConn();
$term = $_GET['term'];
$arr = array();
$sql = "SELECT * FROM tCustomers WHERE name LIKE '%".$term."%' ORDER BY name ASC";
$result = $DB->query($sql);
if ($result != 0)
{
while ($row = $result->fetch_assoc())
{
array_push($arr, $row["name"]);
}
mysqli_free_result($result);
echo json_encode($arr);
}?>
If I insert the getConn function (function getConn(){and all the contents of the function}) into the autoCustomer.php file, it works perfectly, but when I try to use the getConn function from the remote file it fails returning a 500 (Internal server error) fail.
How can I include the database.php file in this autoCustomer.php?
I've tried:
include_once($_SERVER['DOCUMENT_ROOT'].'/globals.php');
include($rootpath.'/rt/database.php');
$rootpath is a variable that gets updated in globals.php.
Also, to simplify I've tried:
include('127.0.0.1/rt/database.php');
No luck in both cases...
Any idea?
What I have tried:
Tried to use different syntax for the include part... no luck with any.