/    Sign up×
Community /Pin to ProfileBookmark

Fetching arabic text from mssql DB

Hi,

I am

$sql = “SELECT * ,convert(nvarchar(100),Grade_Ar) as converted
FROM mdm_grade
“;
$query = sqlsrv_query($conn,$sql) or die(“Error in SQL: $sql”);
while ($row = sqlsrv_fetch_array($query)) {
$Grade_Ar = $row[‘Grade_Ar’];
echo “$Grade_Ar<br/>”;
}

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@themoonauthorAug 05.2018 —  Hi,

I am using PHP 5.4.3 with mssql server DB.

I have an issue in displaying correct Arabic text from the database tables.
whenever, i fetch arabic text from the database, it is showing as ???????
However, if i echo an arabic text in my script, it is showing correctly as it is.
My column data type is nvarchar (100).

Below is my code.

<?php
$sql = "SELECT * ,convert(nvarchar(100),Grade_Ar) as converted
FROM mdm_grade
";
$query = sqlsrv_query($conn,$sql) or die("Error in SQL: $sql");
while ($row = sqlsrv_fetch_array($query)) {
$Grade_Ar = $row['Grade_Ar'];
echo "$Grade_Ar<br/>";
}

?>
Copy linkTweet thisAlerts:
@themoonauthorAug 05.2018 — i got it fixed by adding

"CharacterSet" => "UTF-8"

in my connection string.

Link for more details:

https://stackoverflow.com/questions/3253214/php-get-arabic-content-from-sql-server


cheers

?
Copy linkTweet thisAlerts:
@rootAug 05.2018 — > @themoon#1594587 I am using PHP 5.4.3 with mssql server DB.

WHAT ???

You should be upgrading PHP5 immediately to resolve all the security issues in earlier P{HP versions.
×

Success!

Help @themoon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...