Chinese database content within dynamic PHP pages using CodeIgniter - database

I'm trying to pull Chinese database content to some dynamic PHP pages within our CodeIgniter website. The PHP files that make up each page are encoded as UTF-8 which displays static Chinese text correctly. However, all Chinese content from the database is rendered as question marks.
For example 中华人民共和国 in the database shows up as ???????.
As with the PHP code, all tables are collated as utf8_unicode_ci. The data shows correctly in the database. Any ideas? Many thanks!

This is now sorted. Line 50 of database.php in root -> application -> config should have read:
Correct:
$db['default']['char_set'] = "utf8"
Incorrect:
$db['default']['char_set'] = "UTF-8"
Something so simple! I hope that might help others.

Related

Codeigniter 4 - Emojis stored in database differ from they are displayed in html page

I am new in Codeigniter 4, and I am working on a tutorial related to Emojis.
I got the problem that I spent a week on the internet with the hope to find out a solution. Unfortunately, nothing can solve the issue. Hope you can help me out.
Issue description:
I followed the link from Github emojionearea that assisted me with creating an Emoji picker.
It run perfectly until I submitted an emoji to database and retrieved it from DB to show in a webpage.
I selected an emoji, for example the Man Technologist emoji, it was showed in the input field as One Emoji (see the screenshot "Before submitting" below), which is what I want.
Before Submitting
After I submitted it to the database and retrieved to display in a page, I realised that there are two emojis have been saved (see "After Submitting" screenshot below).
After Submitting
That is the issue I want to be helped.
Following is my Database Settings:
I set DB, DB tables and columns to the charset utf8mb4 and collations to utf8mb4_unicode_ci.
I run SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'; in phpmyadmin SQL to see the current status of my Database with the Charset set. It shows as below:
DB Charset
In the file Database.php in Config folder, I set as below:
enter image description here
In my php view, I included the code <meta http-equiv="Content-type" content="text/html" charset="utf-8"> in the header.
Done descripting my issue.
Please help me go throught and fix this problem.
Thank you!
I tried to change to many charsets for database.
I was expecting that Database got exactly as the emoji displayed in a page before being submitted to Database.
It says on the Emojionearea github page that "The end result is a secure text/plain in which the image icons will be replaced with their Unicode analogues." So what is saving to the database is the unicode version of the Emojione image you picked.
To convert the unicode back to an Emojione image, install the PHP Toolkit for the Emojione library:
https://github.com/joypixels/emoji-toolkit/blob/master/INSTALLATION.md
composer require joypixels/emoji-toolkit
Then use this toolkit to convert the unicode back to an image:
https://github.com/joypixels/emoji-toolkit/blob/master/examples/PHP.md
use JoyPixels\Client;
use JoyPixels\Ruleset;
$client = new Client(new Ruleset());
echo $client->toImage($inputText);
Emojionearea seems to be using an older version (3.1.2) of Emojione by default, so you might want to create an extension of the Client class to set the toolkit to the same version, as the images for the various versions are slightly different:
<?php
namespace App\Libraries;
use JoyPixels\Client;
class Emoji extends Client
{
public $emojiVersion = '3.1'; // 3.1.2 does not seem to work
}
Then use this class instead to convert the unicode string into an image:
use App\Libraries\Emoji;
use JoyPixels\Ruleset;
$client = new Emoji(new Ruleset());
echo $client->toImage($inputText);

After importing database from test to live Arabic text issue

I have imported database table from the localhost to the public host (live server).
On the live server database(backend), Arabic text is appearing properly but when I search data on webpage (php), Arabic text appearing like ????? this. anyhow, with entering new data working fine.
Any help will be highly appreciated

Drupal - Site transfer. Change absolute URLs in the database?

I have content in drupal (Blocks, Pages etc.) where absolute links have been inserted. I moved the site and the urls in the blocks and pages are still pointing to the old domain.
How can I change this in the database? Which database table do I need to target? I want to do something like:
UPDATE table SET content = REPLACE(content,'www.domain.com/old','www.domain.com/new');
Thanks!
Drupal it self is not using absolute paths (like i.e. WordPress does) so moving "common" Drupal websites doesn't require any intervention like this.
My advice is to always use root relative paths for internal links.
Basically you would have to replace ALL appearances of old domain with new one, so it would be best to export your database to sql file, do search/replace on that sql file and then import changed dump file to new domain database. Maybe clear all the caches before database export to reduce database size...
Backup your database first!
Install Adminer script and search whole database for previous (old) domain name. Or build SQL-query to search all tables if you like command line interface
See How to search and replace all instances of a string within a database? to know how to replace string in whole database.
Making this change to the database may not be the best practise, why don't you instead try using the base html tag within the head tag in the .html template file:
<head>
<base href="http://www.domain.com/new"
</head>
Refer to for more information on this tag: http://www.w3schools.com/tags/tag_base.asp

serving pictures from database using nodejs

I am working on a web app and I want to serve users some of their own pictures that I will have stored in a database. I have a profile page view were I have some jade template. I want to load the users pictures when they click on their profile but I do not know where to start with that (I am relatively new to node). I have tried using google but no useful answers have come up. How can I load the user specific pictures from a database using nodeJS?
Any help is appreciated, thank you.
Never store image into db. It's wrong. Store path, url or other, but not Image Binary.
Retrieve url that you have stored into db and put them into your final html.
M.

Joomla 1.7 where are image paths stored for articles?

I've been tasked to migrate a Joomla 1.7 site to Drupal, which is going fairly well, except that I can't find where Joomla stores image paths for articles in the database. In the jos_articles table I have the following columns:
id
title
subtitle
cat
atype
theme
topics
intro
description
geography
source
author
extraauthors
published
featured
created_date
publish_date
unpublish_date
modified_date
hits
Any ideas?
EDIT: figured it out - the template automatically looks for [article-id].jpg, which means they aren't stored in the database at all!!!
Nothing to see here folks...
Joomla keeps information from the articles and pages that you create in two places. First of all, the text of the articles are keep as records in a database. All Joomla sites use a database to keep a lot of the information that helps manager the site, and your articles (and links, and contact items, etc.) are in that database. Generally, the database is provided by a database called mySQL that is provided as part of your web hosting service. Joomla manages getting articles in and out of this for you automatically.
So, you will not find a “file” on your website that contains the text of your articles. It is stored away in the Joomla mySQL database.
Now, photos, icons, graphics, and things like that are not stored in the database. They are actually stored as files in the file system of your Joomla installation.
Check this Article:
http://welcometojoomla.com/how-do-i-articles/34-site-management/76-where-does-joomla-keep-the-articles
By reading below article you will get the answer.
Does joomla store article/ modules text and image path in database?
Where does Joomla store article images?
Where does Joomla keep the articles?
In Joomla 1.7 the Article image urls are stored inside the #__content table
It was saving image url inside the introtext column with the article content. The images are from different location like images/banners/ or from any folder that access from media manager.
Hope its helps.

Resources