So I have this piece of code that is not returning anything (the echo returns nothing and should be returning two rows):
<?php
include "connection.php";
$cliente = $_POST["cliente"];
$select = "SELECT CLIENTE, NOMCLI FROM CLIX1 WHERE NOMCLI LIKE ? ORDER BY NOMCLI";
$stmt = odbc_prepare($con, $select);
//preparing the array for parameter
$prep_array = array();
$prep_array[] = "'%$cliente%'";
$rs = odbc_execute($stmt, $prep_array);
$nombres = array();
$clienteIDS = array();
//if prepare statement is successful
if($rs)
{
$i = 0;
while($row=odbc_fetch_array($stmt))
{
$cliente_id = trim($row["CLIENTE"]);
$nombre = utf8_encode(trim($row["NOMCLI"]));
$nombres[$i] = $nombre;
$clienteIDS[$i] = $cliente_id;
$i++;
}
echo json_encode($nombres) . "|" . json_encode($clienteIDS);
}
else
{
echo "error";
}
odbc_close($con);
?>
I know the problem is not the parameter pass on the odbc_execute() because even if I do this, it doesn't return anything(with %mich% it should display two rows):
$rs = odbc_execute($stmt, array("%mich%"));
Do you see anything wrong in this code?
Please let me know and thanks in advance.
UPDATE ------
I made the changes on the code that were suggested on the answer below and I am getting a new error now:
Warning: odbc_execute(): Can't open file %mich%
Where mich is the text entered to search on the database.