Welcome Guest, Not a member yet? Register   Sign In
Why is row id interpreted as �
#1

Hi ,

I am converting an existing project to Ci4.  but when I get data from the database all the row id's are displayed as �

example
PHP Code:
<select id="salutation" class="form-control">
                            <?php foreach($salutations as $salutation):?>
                            <option value='<?= esc($salutation['id']);?>'><?= esc($salutation['data_label']);?></option>
                            <?php endforeach ?>
                        </select> 
outputs this ...
Code:
<select id="salutation" class="form-control">
      <option value="�">Mr</option>
      <option value="�">Mrs</option>
      <option value="�">Mr &amp; Mrs</option>
      <option value="�">Miss</option>
</select>


MY configuration is as follows

app/config/Database.php

public $default = [
'DSN'      => '',
'hostname' => 'localhost',
'username' => 'xxxxxxx',
'password' => 'xxxxxxx',
'database' => 'xxxxxxx',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 3306,
];


My Table
Charset utf8
Collation utf8_general_ci

php.ini
default_charset = "UTF-8"

html doc
Code:
<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


I've never had this problem before Ci4 and can't for the life of me figure out what is going on.

Any suggestions ???

Many thanks
Reply
#2

On further investigation. I have found that single INT chars 1 - 9 output �    01, 02, 03 .. 11, 12, 13 etc do run into this problem.

I have also tested on Firefox, IE and Edge and INT chars 1 - 9 output �  in all instances.

Again, I have only seen this issue since using Ci4.

Thank you.
Reply
#3

After much soul searching and google searching, I do not believe single character data is "liked", and seems to cause more trouble than it's are worth. In addition, I have found Ci4 prepared queries (this may not be limited to Ci4)do not like working with single character data, for example when trying to insert data that is a single character, the error "Uninitialized string offset: 1" is returned.

Therefore to overcome this specific issue on the Ci4 framework, my table auto increment id's now start from 10 rather than 1.

Also, I do not store single character data (y,n or a,b,c or 1,2).

Maybe the practices I deployed in the past were bad practices or things have just moved on, still this works for me.
Reply
#4

(06-16-2020, 07:30 AM)68thorby68 Wrote: After much soul searching and google searching, I do not believe single character data is "liked", and seems to cause more trouble than it's are worth. In addition, I have found Ci4 prepared queries (this may not be limited to Ci4)do not like working with single character data, for example when trying to insert data that is a single character, the error "Uninitialized string offset: 1" is returned.

Therefore to overcome this specific issue on the Ci4 framework, my table auto increment id's now start from 10 rather than 1.

Also, I do not store single character data (y,n or a,b,c or 1,2).

Maybe the practices I deployed in the past were bad practices or things have just moved on, still this works for me.

Try to open any file with an editor, notepad ++ or even notepad, and check the code of the file, as in the attached image.

Attached Files Thumbnail(s)
   
Reply




Theme © iAndrew 2016 - Forum software by © MyBB