hi
i have a script that works perfectly, but i want to change to mysqli
so, the mysql is
and the result is:PHP Code:<?php
include("includes/banco.php");
$theclass->conecta();
$consulta= "design";
$rs = mysql_query('select profissao from empregos where profissao like "'.$consulta .'%"');
$data = array();
if ( $rs && mysql_num_rows($rs) )
{
while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
{
$data[] = array(
'label' => $row['profissao']
);
}
}
echo json_encode($data);
flush();
?>
the mysqli at the moment isCode:[{"label":"Design"},{"label":"Design Gráfico"},{"label":"Design"},{"label":"Design"}]
ant the result isPHP Code:<?php
include ('includes/includesMy.php');
$consulta= "design";
($sql = $db->prepare('select profissao from empregos where profissao like ?'));
$sql->bind_param('s', $consulta);
$sql->execute();
$sql->bind_result($profissao);
$data = array();
while ($sql->fetch()) {
$data[] = array(
'label' => $row['profissao']
);
}
echo json_encode($data);
$sql -> close();
$db -> close();
?>
Code:[{"label":null},{"label":null},{"label":null}]
the mysqli is not working correctly, the number of outputs are different and label are null (only matches the specific word design and not design gráfico )
any help?




many thanks


Bookmarks