Jump to content

[Solved] Character encoding


labbinat

Recommended Posts

4 hours ago, labbinat said:

encoding the Arabic language for the data coming from the database

The Arabic language coming out of the database is properly encoded, as I tested here 

Unless you can provide further details such as, which software you're using we might be able to help you more, but as far as I can tell the database is working perfectly. We have over 5000 users, many of which are from countries that also speak Arabic, and you're the only one claiming it doesn't work, so it makes me think it's probably your software or your settings.

4 hours ago, labbinat said:

installing the PHPMAILER package to send and receive emails

Here's the instructions on how to install PHPMailer https://github.com/PHPMailer/PHPMailer#installation--loading You can use Composer through Plesk, or you can just run Composer on your home PC and then upload the directory structure it creates.

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

Honestly, I don't know why. If you look at the previous images, you will find that only Arabic texts received from the database appear in this form: "??????????" Maybe because the server is in Latin

I tested my Sabva website and hosted it on two hosting sites and did not suffer from any problems

I liked dealing with you, so I am trying to solve the problem
Please help me find out why

Link to comment
Share on other sites

I did some more testing on your account and your database. How does this look?

 image.png.5b407f985ff9d5e6ca55e487c2462d64.png

Here is the working link https://labbinat.com/krydos.php

Here is the code

<?php

ini_set('default_charset','UTF-8');
header ('Content-Type: text/html; charset=UTF-8');
echo '<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />';
echo '<body dir="rtl">';

$db_host = "localhost";
$db_user = "labbinat_krydos";
$db_pass = "<password>";
$db_data = "labbinat_mydate";
$con = new mysqli($db_host, $db_user, $db_pass, $db_data);
if ($con->connect_error) die("Connection failed: ".$con->connect_error);
$con->set_charset("utf8");
$stmt = $con->prepare("select course_name from courses");
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
while ($row = $result->fetch_assoc()) {
    echo $row["course_name"]."<br>";
}

I think the most important line that you might be missing is $con->set_charset("utf8");

Link to comment
Share on other sites

I downloaded the package to the project folder and it was working previously and this is the code that fetches it

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;


require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

 

But now I am getting this error

"
Fatal error: Uncaught Error: Class "PHPMailer\PHPMailer\Exception" not found in /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php:2233 Stack trace: #0 /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php(2019): PHPMailer\PHPMailer\PHPMailer->smtpConnect() #1 /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php(1678): PHPMailer\PHPMailer\PHPMailer->smtpSend() #2 /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php(1516): PHPMailer\PHPMailer\PHPMailer->postSend() #3 /home/labbinat.com/httpdocs/process_registration.php(139): PHPMailer\PHPMailer\PHPMailer->send() #4 {main} thrown in /home/labbinat.com/httpdocs/PHPMailer/src/PHPMailer.php on line 2233"

Link to comment
Share on other sites

Look at https://github.com/PHPMailer/PHPMailer#installation--loading

image.png.0771a54e0d440e06bcfaff87a4ad452e.png

and compare it to yours

9 hours ago, labbinat said:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

You're missing this line

require 'path/to/PHPMailer/src/Exception.php';

So of course you get an error saying

9 hours ago, labbinat said:

Class "PHPMailer\PHPMailer\Exception" not found

because you didn't load the code for it.

Link to comment
Share on other sites

This error appears

فشل في إرسال البريد الإلكتروني: SMTP Error: Could not connect to SMTP host. Failed to connect to serverSMTP server error: Failed to connect to server SMTP code: 111 Additional SMTP info: Connection refused

 

The strange thing is that the page and email sending were working previously. I don’t know why these errors appeared

 

Link to comment
Share on other sites

   $mail->isSMTP();
            $mail->Host = 'smtp.gmail.com';
            $mail->SMTPAuth = true;
            $mail->اسم المستخدم = '<removed>';
            $mail->Password = '<removed>';
            $mail->SMTPSecure = 'ssl';
            $البريد->المنفذ = 465;

            $mail->setFrom('<removed>', 'LABBINAT');
            $mail->addAddress($email);

            $mail->isHTML(true);
            $mail->CharSet = 'UTF-8';

Link to comment
Share on other sites

It's because the code you're using relies on "simple authentication" (a username and password), but gmail requires a standard called xoauth for scripts to send email through it. Gmail removed support for simple authentication recently.

You need to either use a different email provider that still supports simple authentication (like the mail server on Johnny) or rewrite the code to implement xoauth. Here's a guide on how to use gmail with phpmailer to make a basic sending script: https://phppot.com/php/sending-email-using-phpmailer-with-gmail-xoauth2/ It's not nearly as simple but is the supported way of doing it now.

Link to comment
Share on other sites

  • Krydos changed the title to [Solved] Character encoding

I apologize for returning again, but the application tells me that the message has been sent to the user's email, and there are no messages sent and no messages are received by the user. I searched for the reason and this was the response.

“Verify that firewalls and security software on the server or device where the code is hosted are not blocking the sending process. Some security or firewalls may be blocking access to mail servers.”

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...