0

I have the next code which shows no results:

<?php include ("access.php");
$corpustitle = "Korpus Bilingüe Alemany-Català (de)";
$result = mysqli_query($dbiac, "SELECT corpus FROM corpus_info WHERE title = '$corpustitle'") or die(mysqli_error($dbiac));
while($row = mysqli_fetch_array($result)){ 
echo $row['corpus']."<br>";
} ?>

But if I take the WHERE statement out of the query I get next results:

$result = mysqli_query($dbiac, "SELECT corpus FROM corpus_info") or die(mysqli_error($dbiac));
  • banctraddeucat_ca
  • banctraddeucat_de
  • banctraddeuspa_de
  • ...etc.

And also if I do the original query at the phpmyadmin I get the result I'm looking for:

enter image description here

Andrés Chandía
  • 999
  • 1
  • 16
  • 32

1 Answers1

0

Yes, after @delboy1978uk comments I added this line before the query, and that made the difference:

mysqli_set_charset($dbiac, 'utf8');

So the entire code now is:

<?php include ("access.php");
$corpustitle = "Korpus Bilingüe Alemany-Català (de)";
mysqli_set_charset($dbiac, 'utf8');
$result = mysqli_query($dbiac, "SELECT corpus FROM corpus_info WHERE title = '$corpustitle'") or die(mysqli_error($dbiac));
while($row = mysqli_fetch_array($result)){ 
echo $row['corpus']."<br>";
} ?>

Thanks...

Andrés Chandía
  • 999
  • 1
  • 16
  • 32