I am not very experienced with database and php and I have a problem.
I have made a simple database in phpadmin on a webserver with a table called NEWS with 3 columns called int ID, text RUBRIK, text ARTICLE.
When i use SELECT * FROM NEWS the result from ID and RUBRIK works well but the result from ARTICLE returns "null". Do anyone know what is wrong.
In phpmyadmin it works perfect to add column with text that contains the swedish letters and in phpmyadmin it is possible to see the stored text in a correct way, it is when the text is called to the php it wont work.
I use a index.php file interact with the database, because index.php is just working for connecting my android application with the database the answer from index.php is print(json_encode($output));
PS, I have tried saving the index.php file in MS Notes with ANSI and UTF-8 coding. Makes no difference, I have tried manipulating my database by changing all collations I can find in the phpmyadmin between latin1_general_ci, utf8_general_ci, utf8_general_bin, utf8_swedish etc etc.
I have also tried the command mysql_query("set names utf8"); which I was recommended to try, using that made the database return the letters in the similar to "/&aumi".
Would really appreciate if anyone could help me.
Here is the php file.
<?php
$con = mysql_connect("mysqlserver","user","passwords");
if(!$con)
{
die(' funkar ej: ' . mysql_error());
}
mysql_select_db("database", $con);
$q=mysql_query("SELECT * FROM NEWS");
while($e=mysql_fetch_assoc($q))
$output[]=$e;
print(json_encode($output));
mysql_close();
?>
Try encoding inside the php with
utf8_encode ( string $data )Encoding each$ewith it.