0

I have a table that has about 200K rows of data. Overall it works great. I have two different pages where users can submit data to be inserted into this table. Both work fine, except when it comes to languages like Arabic. One continues to work fine however the other one inserts total gibberish. The PHP code in both cases is almost identical.

The page that woks fine submits data to a PHP script via form POST. When I check for the encoding type of the data it shows as ASCII.

The page that is acting up uses JS to submit data via ajax to another PHP script. When I check for data encoding on that page it shows as UTF-8.

Here's my table's info:

CREATE TABLE `uiCardCategories` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `project_id` INT(10) UNSIGNED NOT NULL,
    `catCreator_id` INT(11) NULL DEFAULT NULL COMMENT 'id of the user who created this stack',
    `catCreator_participantID` INT(11) NULL DEFAULT NULL COMMENT 'id of the participant who created this stack',
    `label` VARCHAR(400) NOT NULL,
    PRIMARY KEY (`id`, `project_id`),
    INDEX `ix_uiCardCategories_project_creator_id` (`project_id`)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM
AUTO_INCREMENT=160880
;

I tested with the phrase "this is a test, in Arabic "هذا اختبار". Data in the table is:

هذا اختبار

What am I missing?

santa
  • 12,234
  • 49
  • 155
  • 255
  • How is this a "php" question? Are you connecting/querying also, or is this just a "mysql" issue? If it's "php", there's surely a reason but I can't say that for sure, since I/we don't know what else is at play here. So in that respect, the question for me is unclear. – Funk Forty Niner Nov 21 '19 at 20:44
  • I'm betting on encoding/connection. Where UTF-8 all the way through should be used in all files related to this. – Funk Forty Niner Nov 21 '19 at 20:45
  • Fixed by re-writing all routines to PDO. – santa Nov 22 '19 at 22:03
  • I'm glad to hear that. – Funk Forty Niner Nov 22 '19 at 22:07
  • Btw. If none of the duplicates used to close your question with didn't address anything that you used to fix your code with, I'd be glad to reopen and you could post your own answer. I'd be glad to support it, given that none of the duplicates were used for it. There needs to be something quite special and unique in order to add to the Stack Q&A. – Funk Forty Niner Nov 22 '19 at 22:12

0 Answers0