try { $conn = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass); } catch(PDOException $e) { } if ($conn) { $ac_term = "%".$_GET['term']."%"; $query = "SELECT * FROM utwory where tytul like :term"; $result = $conn->prepare($query); $result->bindValue(":term",$ac_term); $result->execute(); /* Retrieve and store in array the results of the query.*/ while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $row_array['id'] = $row['uid']; $row_array['value'] = $row['tytul']; } } /* Free connection resources. */ $conn = null; /* Toss back results as json encoded array. */
niestety nie mam pojęcia czemu jak jest polski znak w rekordzie to cały rekord jest wyświetlany jako "null"
przykładowo uid=299; tytul=Trędowata marionetka; zwraca:
{"id":"299","value":null}
nie wiem czemu tak się dzieje i jak to naprawić, kodowanie bazy utf8_polish_ci, pliku utf-8 bez bom