0

I'm trying to get different band names, but then i type $Band = "Azuolas" and $Band="Ąžuolas" I gate both at the same time. how can I fix this?

$band =$_POST['band_name'];
$sql= "SELECT  Band FROM Songs WHERE Band='".$band."' ";
$query_run =mysqli_query($con, $sql);
while($mysqli_fetch_assoc =mysqli_fetch_assoc($query_run)){
echo $mysqli_fetch_assoc['Band']."<br>";
}

1 Answers1

1

Assuming you're going for UTF8 support, follow all of the steps outlined in this post. e.g.

  • Set your web page charset to UTF8.
  • Make sure your PHP script file is saved in UTF8.
  • Run SET NAMES 'utf8' on your database immediately after making the connection.
Community
  • 1
  • 1
Matt S
  • 14,976
  • 6
  • 57
  • 76
  • You shouldn't run `SET NAMES` manually unless you're using a very old PHP library that doesn't support it (and I mean *very* old). Mysqli has `set_charset()` since PHP/5.0.5 – Álvaro González Mar 10 '16 at 16:24
  • `SET NAMES` is the only SQL standard method that is guaranteed to work with all libraries. No reason to ignore a SQL standard. – Matt S Mar 10 '16 at 16:26
  • What SQL standard? It's a MySQL-only command and it's [specifically discouraged](http://php.net/manual/en/mysqlinfo.concepts.charset.php) in the PHP manual. – Álvaro González Mar 10 '16 at 16:31
  • http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt http://savage.net.au/SQL/sql-92.bnf.html Works across all standard database and libraries. There is absolutely no reason to not use it. – Matt S Mar 10 '16 at 16:41
  • Alright, I wasn't aware it was defined in SQL92. But it doesn't work in my SQL Server 2008 and Oracle 11g installations (not at least out of the box). And, yes, there's a reason to not use it, it's explained in the PHP documentation I've linked (it informs the server about the encoding change but not the client). If you are honestly convinced that the PHP documentation is wrong I think you should file a bug and get it fixed in the source. – Álvaro González Mar 10 '16 at 17:12