Help with PHP and Mssql special characters

Asked

Viewed 923 times

1

I’m making a form, and when I record the information with special characters, record it well... only when I rescue the information it comes encoded... already used , utf8_encode/Decode and nothing I do not know if it is in php or in the bank that I have to move... detail, I have no autonomy to deal directly with the Mssql database...

A brief example:

JOHN PATIENCE

when I use: $NOME = utf8_encode($row['NOME']); -> He brings the following: "JO? THE PATIENCE"

when I use: $NOME = utf8_decode($row['NOME']); -> He brings the following: "JO? O PACI? NCIA"

When I use: $NOME = ['NOME']; -> He brings the following: "JO? THE PACIENCE"

I don’t know if it’s the comic book or the programming I move... Thank you so much!

  • 3

    Is your database utf8 or latin1? Is your PHP configured to use utf8 or iso-8859-1? Your text is confusing and the codes posted too, please edit the question and provide an example that can be reproduced.

  • 1

    What database driver is using? mssql, sqlsrv, PDO, adodb?

  • @Guilhermenascimento I’ll see an editing mode that doesn’t get so confused...

  • @Read this: http://answall.com/a/43205/3635 this is likely to help

  • Another strange thing is that the ã was like ? and the ê was like , to me it seems that it has mixed dice. I do not know to say.

5 answers

1


in your data bank, the collation has to be set to utf8_geneal_ci or something related, in your php you have to format to utf8 without good and in the connection of the database you have to instruct the consideration of set Nane utf8 or something related in mssql and at the time of inserting or reading the information you can not encoder or decode or it will generate conflict

  • Yeah, I didn’t want to have to mess with the bank because it was old and connected to a system but there was no way... I had to, thank you for your time and help!

0

In addition to formatting the text, what page formatting are you using? You have to see the page formation and which charset is set in HTML. A charset conflict and HTML formatting can generate these types of errors.

I hope I’ve helped.

0

What collation are you wearing on the bench?

When you add the information in the bank you are doing their code? Ex: $novoNome = utf8_decode($_POST['nome']);

-3

Before the SQL statement puts the following expression:

mysql_query("set names 'utf8'");
  • 1

    It is using SQL Sever(mssql) and not mysql. There is something similar in mssql(old extension), see and in the manual

  • ini_set('mssql.charset', 'UTF-8'); arrow it

-3

It was with a problem seems in the register of names with special characters and with apostrophe in the names, use iso 8859-1 and utf8.

RESOLVED THAT WAY > $data['name'] = addslashes(utf8_encode($data['name']));

maybe it’ll help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.