Narendra Verma Narendra Verma - 3 years ago 191
PHP Question

Added Meta tag UTF 8 but the character encoding of the HTML document was not declared still getting it

I am getting error in console even I added UTF-8

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.

I already added in HMTL head.

<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">

If I delete below my PHP code from HTML then It's working properly

values comes from

if ($conn->real_escape_string($_GET['key'])){
$decrypted_p_id = decryptIt($p_id);
/*display single products*/
$sql_single_products="SELECT p_images, p_name, p_company, p_status FROM products WHERE p_id=?";
if ($stmt = $conn->prepare($sql_single_products)) {
$stmt->bind_param("i", $decrypted_p_id);
$stmt->bind_result($p_images, $name,$company,$status);

Below Is the function to change my ID encryption to decryption and vice and versa

function encryptIt( $q ) {
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
return( $qEncoded );

function decryptIt( $q ) {
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qDecoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
return( $qDecoded );


$servername = "localhost";
$username = "user";
$password = "Pass#@123";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

After adding
in database connection file getting
and also added
ini_set('display_errors', 1);
then I am getting error

Allowed memory size of 268435456 bytes exhausted (tried to allocate 4294967296 bytes)

Answer Source

Finally, I found my answer. What I did, I created a php.ini file in the public_html folder and added below code in it.

memory_limit = 512M // before it was 256M if you want to check the current limit then add  `php_info();` in your PHP file then run your file.and find memory_limit.
post_max_size = 32M;
upload_max_filesize = 32M;

but still, I was getting the issue. I was using prepared statement then I added


before $stmt->bind_result() and this time it was working perfeclty.

If anyone getting the same issue then try this solution.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download