Hi. I just launched my first ever website. I built the backend using phpmyadmin and php logic sheets. On the local server the text for the articles was written in google docs, pasted into phpmyadmin, and came out perfectly, including but not limited to the special arabic characters. Now that I’m hosting the website on domain.com many characters like quotation marks and the arabic letters are being replaced with question marks. The database collation settings etc. are exactly the same, and the HTML meta data is exactly the same (UTF-8). The only different I can see is that the PHPmyadmin on my web hosting service is a different version to the one I used on the local host. This seems to be a common problem but I can’t find a clear answer on how to rectify it. If anyone could shed some light on this it would be much appreciated.
When you use phpmyadmin to view the stored data does it display correctly and this is only a problem when you use php to query for, retrieve, and display the data?
What php database extension are you using and are you setting the character set to match your database tables when you make the database connection?
yes the text all looks perfect in phpmyadmin, it only messes up on the dynamic sheets now that i’ve gone live. I’m not using an extension to my knowledge, but I’m very new to this so let me double check.
No, on the logic sheet to connect to the database i have not set the character set, but it’s exactly the same as when it was on a local server and there it was working fine.
I’ll look at adding the character set on the script where the database connection is. Could you point me in the right direction of how to do that? i’m extremely grateful for your response.
From the information in this thread, all we know is you have a MySQL/MariaDB database somewhere, because that’s all that the phpmyadmin tool is capable of managing. It would take having all the code needed to reproduce the problem, without any private information, such as the connection credentials, in order to offer any help.
<?php
// Don't display server errors
ini_set("display_errors", "off");
// Initialize a database connection
$conn = mysqli_connect("host", "username", "password", "database_name");
// Destroy if not possible to create a connection
if(!$conn){
echo "<h3 class='container bg-dark p-3 text-center text-warning rounded-lg mt-5'>Not able to
establish Database Connection<h3>";
}
// Get data to display on index page
$sql = "SELECT * FROM lifestyle";
$query = mysqli_query($conn, $sql);
// Create a new post
if(isset($_REQUEST['new_post'])){
$metadescrip = $_REQUEST['metadescrip'];
$metakey = $_REQUEST['metakey'];
$author = $_REQUEST['author'];
$tagwords = $_REQUEST['tagwords'];
$datefull = $_REQUEST['datefull'];
$title = $_REQUEST['title'];
$tagline = $_REQUEST['tagline'];
$authorpic = $_REQUEST['authorpic'];
$introp = $_REQUEST['introp'];
$heropic = $_REQUEST['heropic'];
$heropiccap = $_REQUEST['heropiccap'];
$block1 = $_REQUEST['block1'];
$quote = $_REQUEST['quote'];
$pic2 = $_REQUEST['pic2'];
$pic2cap = $_REQUEST['pic2cap'];
$block2 = $_REQUEST['block2'];
$quote2 = $_REQUEST['quote2'];
$pic3 = $_REQUEST['pic3'];
$pic3ccap = $_REQUEST['pic3ccap'];
$block3 = $_REQUEST['block3'];
$sql = "INSERT INTO lifestyle( metadescrip, metakey, author, tagwords, datefull, title, tagline, authorpic,
introp, heropic, heropiccap, block1, quote, pic2, pic2cap, block2, quote2, pic3, pic3ccap, block3)
VALUES('$metadescrip', '$metakey', '$author', '$tagwords', '$datefull', '$title', '$tagline', '$authorpic',
'$introp', '$heropic', '$heropiccap', '$block1', '$quote', '$pic2', '$pic2cap', '$block2', '$quote2', '$pic3,'
'$pic3ccap', '$block3')";
mysqli_query($conn, $sql);
}
// Get post data based on id
if(isset($_REQUEST['id'])){
$id = $_REQUEST['id'];
$sql = "SELECT * FROM lifestyle WHERE id = $id";
$query = mysqli_query($conn, $sql);
}