[solved in next update 3.5]PHP error and warning with ajax field

Post Reply
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

 [solved in next update 3.5]PHP error and warning with ajax field

Post by Didou12 »

Hi,

I repost about that, I think the problem with ajax field is when I try to get value in a string (from a parent, I didn't test in the current form but I think there is the same issue). My previous post about that is also with a string I think.

When :

Code: Select all

$field = [123];
$form_field_value = $field;
echo $form_field_value;
I have this :

Code: Select all

2023-07-31 01:12	USER Warning	
Trying to access array offset on value of type int
modules/dashboard/actions/ajax_request.php:118
/index.php?module=dashboard/ajax_request&field_id=456&item_id=0 [AJAX]
And the loader just turns round and round.

and if I try this :

Code: Select all

$field = '[123]';
$form_field_value = $field;
echo $form_field_value;
I have this :

Code: Select all

[31-Jul-2023 01:13:55 America] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /***/***/***/modules/dashboard/actions/ajax_request.php:118
Stack trace:
#0 /***/***/***/index.php(20): require()
#1 {main}
  thrown in /***/***/***/modules/dashboard/actions/ajax_request.php on line 118
And the loader just turns round and round too.
Last edited by Didou12 on 05 Dec 2023, 11:48, edited 1 time in total.
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
User avatar
nehakakar
Posts: 4
Joined: 04 Jul 2023, 11:44
Name: nehakakar
Location: India
Company Name: Alam Groups
Contact:

Re: PHP error and warning with ajax field

Post by nehakakar »

Hi,
In your case, $field is assigned an integer value [123], but it should be assigned an array instead.
Change the assignment to an array ..

Code: Select all

$field = [123];
$form_field_value = $field;
echo json_encode($form_field_value);
Using json_encode will ensure that the array is properly converted to a JSON string for echoing.
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: PHP error and warning with ajax field

Post by Didou12 »

any update ?
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
User avatar
support
Site Admin
Posts: 6231
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: PHP error and warning with ajax field

Post by support »

Probably already fixed for 3.5
I can't reproduce it and code is already updated. So test this once 3.5 will be released.
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: PHP error and warning with ajax field

Post by Didou12 »

perfect

Thank you :)
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Post Reply