Bonjour,
Avez vous une idée comment résoudre cette erreur ?
Cette erreur apparait quand je sauve des données. En résumé je peux mettre dans ma feuille produits des options qui vont s'afficher sous forme de select, radio ...textarea or file à télécharger dans le catalogue
Code : Sélectionner tout - Visualiser dans une fenêtre à part Warning: Illegal string offset 'type'
Si j'utilise uniquement ces éléments comme option : select, checkbox, radio, je n'ai pas de problèmes, tout se passe correctement.
Mais à partir du moment ou je mets un textarea ou un file, j'ai l'erreur qui aparait.
Avez vous une idée de ce qui peut se passer et comment le résoudre ?
Merci.
code :
Résultat de
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 if (isset($_POST['product_option'])) { foreach ($_POST['product_option'] as $product_option) { $type = $product_option['type']; ===> pb de l'erreur ici $option_id = $product_option['option_id']; if ($option_id != 0) { if ($type == 'select' || $type == 'radio' || $type == 'checkbox' || $type == 'image') { if (isset($product_option['product_option_value'])) { $sql_array_option = ['value' => null, 'products_id' => (int)$products_id, 'option_id' => (int)$option_id, 'required' => (int)$product_option['required'] ]; $this->app->db->save('products_option', $sql_array_option); $products_option_id = $this->app->db->lastInsertId(); foreach ($product_option['product_option_value'] as $product_option_value) { ...... } } } } else { if ($type != 'file') { $sql_array_option = ['products_id' => (int)$products_id, 'option_id' => (int)$option_id, 'required' => (int)$product_option['required'], 'value' => $type ]; $this->app->db->save('products_option', $sql_array_option); } else { if (!empty($_FILES['products_download_filename']['name'])) { $sql_array_option = ['products_id' => (int)$products_id, 'option_id' => (int)$option_id, 'required' => (int)$product_option['required'], 'value' => $type ]; $this->app->db->save('products_option', $sql_array_option); ....... } } } } } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part var_dump($_POST['product_option']);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 array (size=7) 0 => array (size=3) 'option_id' => string '43' (length=2) 'type' => string 'radio' (length=5) 'product_option_value' => array (size=1) 0 => array (size=12) ... 1 => array (size=2) 'option_id' => string '44' (length=2) 'type' => string 'select' (length=6) 2 => array (size=2) 'option_id' => string '47' (length=2) 'type' => string 'checkbox' (length=8) 3 => array (size=2) 'option_id' => string '58' (length=2) 'type' => string 'file' (length=4) 'products_option_maxdays' => string '7' (length=1) 'products_option_maxcount' => string '' (length=0) 'download_customers_group_id' => string '0' (length=1)
résultat de:
Code : Sélectionner tout - Visualiser dans une fenêtre à part var_dump($product_option['type'])
résultat de
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Save.php:61:string 'radio' (length=5) Save.php:61:string 'select' (length=6) Save.php:61:string 'checkbox' (length=8) Save.php:61:string 'textarea' (length=8)
Code : Sélectionner tout - Visualiser dans une fenêtre à part var_dump($product_option)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 array (size=3) 'option_id' => string '43' (length=2) 'type' => string 'radio' (length=5) Save.php:60: array (size=2) 'option_id' => string '44' (length=2) 'type' => string 'select' (length=6) Save.php:60: array (size=2) 'option_id' => string '47' (length=2) 'type' => string 'checkbox' (length=8) Save.php:60: array (size=2) 'option_id' => string '55' (length=2) 'type' => string 'file' (length=4)
Partager