CodeIgniter Forums
"message": "Uninitialized string offset: 0" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: "message": "Uninitialized string offset: 0" (/showthread.php?tid=77363)

Pages: 1 2


"message": "Uninitialized string offset: 0" - regimon - 08-21-2020

Code:
{
    "title": "ErrorException",
    "type": "ErrorException",
    "code": 500,
    "message": "Uninitialized string offset: 0",
    "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Database\\Query.php",
    "line": 479,
    "trace": [
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Database\\Query.php",
            "line": 479,
            "function": "errorHandler",
            "class": "CodeIgniter\\Debug\\Exceptions",
            "type": "->",
            "args": [
                8,
                "Uninitialized string offset: 0",
                "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Database\\Query.php",
                479,
                {
                    "sql": "INSERT INTO articles (article_url,article_title,article_slug,\r\n                        article_abstract,article_authors,article_area,article_keywords,article_journal,\r\n                        article_volume,article_issue,article_page_no,article_indexing,\r\n                        article_published_date,article_created_by,\r\n                        article_created_ip,pdf_name,pdf_file,image_file,image_file_name) \r\n                        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
                    "binds": [
                        "https://forum.codeigniter.com/thread-73765.html",
                        "Services in CodeIgniter 4",
                        "services-in-codeigniter-4",
                        "I am not sure if these will work in a filter or not.",
                        "Regimon",
                        "Bio, Html 5, AI, PYTHON",
                        "csadsafdf",
                        "wdsdsafdfdf",
                        "23",
                        "32",
                        "34",
                        "[\"2\"]",
                        "2020-08-22",
                        "1",
                        "::1",
                        "Emergency Permit (1).pdf",
                        "1598072890_18f71a2efad774d07bd8.pdf",
                        "",
                        ""
                    ],
                    "bindCount": 19,
                    "ml": 1,
                    "c": 18,
                    "matches": [
                        [
                            [
                                "?",
                                447
                            ],
                            [
                                "?",
                                449
                            ],
                            [
                                "?",
                                451
                            ],
                            [
                                "?",
                                453
                            ],
                            [
                                "?",
                                455
                            ],
                            [
                                "?",
                                457
                            ],
                            [
                                "?",
                                459
                            ],
                            [
                                "?",
                                461
                            ],
                            [
                                "?",
                                463
                            ],
                            [
                                "?",
                                465
                            ],
                            [
                                "?",
                                467
                            ],
                            [
                                "?",
                                469
                            ],
                            [
                                "?",
                                471
                            ],
                            [
                                "?",
                                473
                            ],
                            [
                                "?",
                                475
                            ],
                            [
                                "?",
                                477
                            ],
                            [
                                "?",
                                479
                            ],
                            [
                                "?",
                                481
                            ],
                            [
                                "?",
                                483
                            ]
                        ]
                    ]
                }
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Database\\Query.php",
            "line": 408,
            "function": "matchSimpleBinds",
            "class": "CodeIgniter\\Database\\Query",
            "type": "->",
            "args": [
                "INSERT INTO articles (article_url,article_title,article_slug,\r\n                        article_abstract,article_authors,article_area,article_keywords,article_journal,\r\n                        article_volume,article_issue,article_page_no,article_indexing,\r\n                        article_published_date,article_created_by,\r\n                        article_created_ip,pdf_name,pdf_file,image_file,image_file_name) \r\n                        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
                [
                    "https://forum.codeigniter.com/thread-73765.html",
                    "Services in CodeIgniter 4",
                    "services-in-codeigniter-4",
                    "I am not sure if these will work in a filter or not.",
                    "Regimon",
                    "Bio, Html 5, AI, PYTHON",
                    "csadsafdf",
                    "wdsdsafdfdf",
                    "23",
                    "32",
                    "34",
                    "[\"2\"]",
                    "2020-08-22",
                    "1",
                    "::1",
                    "Emergency Permit (1).pdf",
                    "1598072890_18f71a2efad774d07bd8.pdf",
                    "",
                    ""
                ],
                19,
                1
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Database\\Query.php",
            "line": 197,
            "function": "compileBinds",
            "class": "CodeIgniter\\Database\\Query",
            "type": "->",
            "args": []
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Debug\\Toolbar\\Collectors\\Database.php",
            "line": 211,
            "function": "getQuery",
            "class": "CodeIgniter\\Database\\Query",
            "type": "->",
            "args": []
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Debug\\Toolbar\\Collectors\\BaseCollector.php",
            "line": 307,
            "function": "display",
            "class": "CodeIgniter\\Debug\\Toolbar\\Collectors\\Database",
            "type": "->",
            "args": []
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Debug\\Toolbar.php",
            "line": 128,
            "function": "getAsArray",
            "class": "CodeIgniter\\Debug\\Toolbar\\Collectors\\BaseCollector",
            "type": "->",
            "args": []
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Debug\\Toolbar.php",
            "line": 353,
            "function": "run",
            "class": "CodeIgniter\\Debug\\Toolbar",
            "type": "->",
            "args": [
                1598072890.424345,
                0.0754,
                {
                    "uri": {},
                    "config": {
                        "baseURL": "http://localhost/works/SciHorizon/public/",
                        "indexPage": "",
                        "uriProtocol": "REQUEST_URI",
                        "defaultLocale": "en",
                        "negotiateLocale": false,
                        "supportedLocales": [
                            "en"
                        ],
                        "appTimezone": "Asia/Calcutta",
                        "charset": "UTF-8",
                        "forceGlobalSecureRequests": false,
                        "sessionDriver": "CodeIgniter\\Session\\Handlers\\FileHandler",
                        "sessionCookieName": "ci_session",
                        "sessionExpiration": 7200,
                        "sessionSavePath": "D:\\Xampp\\htdocs\\works\\SciHorizon\\writable\\session",
                        "sessionMatchIP": false,
                        "sessionTimeToUpdate": 300,
                        "sessionRegenerateDestroy": false,
                        "cookiePrefix": "",
                        "cookieDomain": "",
                        "cookiePath": "/",
                        "cookieSecure": false,
                        "cookieHTTPOnly": false,
                        "proxyIPs": "",
                        "CSRFTokenName": "csrf_test_name",
                        "CSRFHeaderName": "X-CSRF-TOKEN",
                        "CSRFCookieName": "csrf_cookie_name",
                        "CSRFExpire": 7200,
                        "CSRFRegenerate": true,
                        "CSRFRedirect": true,
                        "CSPEnabled": false
                    }
                },
                {
                    "CSP": {}
                }
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Filters\\DebugToolbar.php",
            "line": 78,
            "function": "prepare",
            "class": "CodeIgniter\\Debug\\Toolbar",
            "type": "->",
            "args": [
                {
                    "uri": {},
                    "config": {
                        "baseURL": "http://localhost/works/SciHorizon/public/",
                        "indexPage": "",
                        "uriProtocol": "REQUEST_URI",
                        "defaultLocale": "en",
                        "negotiateLocale": false,
                        "supportedLocales": [
                            "en"
                        ],
                        "appTimezone": "Asia/Calcutta",
                        "charset": "UTF-8",
                        "forceGlobalSecureRequests": false,
                        "sessionDriver": "CodeIgniter\\Session\\Handlers\\FileHandler",
                        "sessionCookieName": "ci_session",
                        "sessionExpiration": 7200,
                        "sessionSavePath": "D:\\Xampp\\htdocs\\works\\SciHorizon\\writable\\session",
                        "sessionMatchIP": false,
                        "sessionTimeToUpdate": 300,
                        "sessionRegenerateDestroy": false,
                        "cookiePrefix": "",
                        "cookieDomain": "",
                        "cookiePath": "/",
                        "cookieSecure": false,
                        "cookieHTTPOnly": false,
                        "proxyIPs": "",
                        "CSRFTokenName": "csrf_test_name",
                        "CSRFHeaderName": "X-CSRF-TOKEN",
                        "CSRFCookieName": "csrf_cookie_name",
                        "CSRFExpire": 7200,
                        "CSRFRegenerate": true,
                        "CSRFRedirect": true,
                        "CSPEnabled": false
                    }
                },
                {
                    "CSP": {}
                }
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\Filters\\Filters.php",
            "line": 199,
            "function": "after",
            "class": "CodeIgniter\\Filters\\DebugToolbar",
            "type": "->",
            "args": [
                {
                    "uri": {},
                    "config": {
                        "baseURL": "http://localhost/works/SciHorizon/public/",
                        "indexPage": "",
                        "uriProtocol": "REQUEST_URI",
                        "defaultLocale": "en",
                        "negotiateLocale": false,
                        "supportedLocales": [
                            "en"
                        ],
                        "appTimezone": "Asia/Calcutta",
                        "charset": "UTF-8",
                        "forceGlobalSecureRequests": false,
                        "sessionDriver": "CodeIgniter\\Session\\Handlers\\FileHandler",
                        "sessionCookieName": "ci_session",
                        "sessionExpiration": 7200,
                        "sessionSavePath": "D:\\Xampp\\htdocs\\works\\SciHorizon\\writable\\session",
                        "sessionMatchIP": false,
                        "sessionTimeToUpdate": 300,
                        "sessionRegenerateDestroy": false,
                        "cookiePrefix": "",
                        "cookieDomain": "",
                        "cookiePath": "/",
                        "cookieSecure": false,
                        "cookieHTTPOnly": false,
                        "proxyIPs": "",
                        "CSRFTokenName": "csrf_test_name",
                        "CSRFHeaderName": "X-CSRF-TOKEN",
                        "CSRFCookieName": "csrf_cookie_name",
                        "CSRFExpire": 7200,
                        "CSRFRegenerate": true,
                        "CSRFRedirect": true,
                        "CSPEnabled": false
                    }
                },
                {
                    "CSP": {}
                },
                null
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\CodeIgniter.php",
            "line": 422,
            "function": "run",
            "class": "CodeIgniter\\Filters\\Filters",
            "type": "->",
            "args": [
                "profile/createArticle",
                "after"
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\system\\CodeIgniter.php",
            "line": 312,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->",
            "args": [
                null,
                {
                    "handler": "file",
                    "backupHandler": "dummy",
                    "storePath": "D:\\Xampp\\htdocs\\works\\SciHorizon\\writable\\cache/",
                    "cacheQueryString": false,
                    "prefix": "",
                    "memcached": {
                        "host": "127.0.0.1",
                        "port": 11211,
                        "weight": 1,
                        "raw": false
                    },
                    "redis": {
                        "host": "127.0.0.1",
                        "password": null,
                        "port": 6379,
                        "timeout": 0,
                        "database": 0
                    },
                    "validHandlers": {
                        "dummy": "CodeIgniter\\Cache\\Handlers\\DummyHandler",
                        "file": "CodeIgniter\\Cache\\Handlers\\FileHandler",
                        "memcached": "CodeIgniter\\Cache\\Handlers\\MemcachedHandler",
                        "predis": "CodeIgniter\\Cache\\Handlers\\PredisHandler",
                        "redis": "CodeIgniter\\Cache\\Handlers\\RedisHandler",
                        "wincache": "CodeIgniter\\Cache\\Handlers\\WincacheHandler"
                    }
                },
                false
            ]
        },
        {
            "file": "D:\\Xampp\\htdocs\\works\\SciHorizon\\public\\index.php",
            "line": 61,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->",
            "args": []
        }
    ]
}



RE: "message": "Uninitialized string offset: 0" - jreklund - 08-21-2020

Hi, we need the code that generates said error. Can't do anything with that debug trace really. Only thing we can say are that you are trying to use an array, that's not an array.


RE: "message": "Uninitialized string offset: 0" - InsiteFX - 08-22-2020

if it is json you need to use :

PHP Code:
$newArray json_decode($the_jsontrue); 

will take the json and give you a php associated array.


RE: "message": "Uninitialized string offset: 0" - regimon - 08-30-2020

(08-21-2020, 11:05 PM)jreklund Wrote: Hi, we need the code that generates said error. Can't do anything with that debug trace really. Only thing we can say are that you are trying to use an array, that's not an array.


Array
(
    [0] => http://localhost:8080/learn/ci4
    [1] => Abstract dsdsdsadsdsds
    [2] => abstract-dsdsdsadsdsds
    [3] => The industrial communication systems, the performances of IEEE802.11 are essential. In which the actions of IEEE802.11 wireless LANs are attracted by the characteristics of the wireless channels which reflects the Signalto-interference-Noise Ratio. Since the y operate in harsh environments of the Industries. If the modulation techniques are adopted at lower data rate and they are considered to be as robust full so IEEE802.11 WLAN specifications are must to adapt with the transmission rate. But these standards are not defining any rate adaptation techniques and they are submitting the adjustment of transmission rate to the device holder’s choice. This paper is mainly focusing on the Rate Adaptation technique for the Communication systems on the industries wish is always facing high reliability and other timer requirements. Here we are comparing the performance of this Rate Adaptation technique with the traditional Auto Rate Fall-back mechanism with set of special experiments.
    [4] => hdhgs,dshdihsdg,dsuhgusgdh
    [5] => AIAIAIAIAIAIAIAIAI
    [6] =>
    [7] => sdsdsd
    [8] => 1
    [9] => 2
    [10] => 5
    [11] => {"0":"3"}
    [12] => 2020-08-19
    [13] => 1
    [14] => ::1
    [15] => 783820460.pdf
    [16] => 1598777106_0bd7919a303e6e792d61.pdf
    [17] => 
    [18] => 
)


RE: "message": "Uninitialized string offset: 0" - jreklund - 08-30-2020

Ok, that's an array. But what are you doing with it?


RE: "message": "Uninitialized string offset: 0" - regimon - 08-30-2020

(08-21-2020, 11:05 PM)jreklund Wrote: Hi, we need the code that generates said error. Can't do anything with that debug trace really. Only thing we can say are that you are trying to use an array, that's not an array.
I am getting this error when i try to insert empty string


RE: "message": "Uninitialized string offset: 0" - jreklund - 08-30-2020

Don't insert an empty string then. We can't help you with the lack of information on how you are doing stuff (code and database design).


RE: "message": "Uninitialized string offset: 0" - InsiteFX - 08-30-2020

In your code that is getting the information for the json you need to loop through it
and check for and empty value.


RE: "message": "Uninitialized string offset: 0" - regimon - 08-30-2020

(08-30-2020, 03:43 AM)jreklund Wrote: Don't insert an empty string then. We can't help you with the lack of information on how you are doing stuff (code and database design).

PHP Code:
$pQuery $this->DB->prepare(function($db)
{
    
$sql "INSERT INTO articles (article_slug,article_url,article_title,
                article_abstract,article_authors,article_area,article_keywords,article_journal,
                article_volume,article_issue,article_page_no,article_indexing,
                article_published_date,article_created_by,
                article_created_ip,pdf_name,pdf_file,image_file,image_file_name)
                VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
;
    return (new 
Query($db))->setQuery($sql);
}); 

this is my prepared statement

PHP Code:
$pQuery->execute("slug","url","title","abstract","authors","areas",
"keywords","journalName","volume","issue","pageNumber","indexing",
"publishDate","creatingAuthor","ip","pdfTitle","pdfFileName","",""); 
the above execute give me error

PHP Code:
$pQuery->execute("slug","url","title","abstract","authors","areas",
"keywords","journalName","volume","issue","pageNumber","indexing",
"publishDate","creatingAuthor","ip","pdfTitle","pdfFileName","test","test"); 

but this one not giving error

if i insert any empty string then having error


RE: "message": "Uninitialized string offset: 0" - jreklund - 08-30-2020

Have you tried this?

PHP Code:
$pQuery->execute("slug","url","title","abstract","authors","areas",
"keywords","journalName","volume","issue","pageNumber","indexing",
"publishDate","creatingAuthor","ip","pdfTitle","pdfFileName",nullnull);