[Skip to main content](#vessel-content)

#   action de masse php avec champ perso

##

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2696
- Thank you received: 74
-
-

4 years 1 month ago -  4 years 1 month ago [\#344933](#344933) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344933 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")* was created by *[erickb](/forum/user/4069-erickb "View erickb's Profile")*

-- HikaShop version -- : 4.6.1

je fais cette action de masse php pour recuperer les valeur du champ perso product_categories Code:

$cats = explode(',',{product_categories}); $db = JFactory::getDBO(); foreach($cats as $c){ $q = 'INSERT IGNORE INTO #__hikashop_product_category (category_id, product_id) VALUES ('.$c.', {product_id});'; $db-&gt;setQuery($q); $db-&gt;execute(); }

mais j'ai une erreur sur explode car le champ perso product_categories n'est pas trouve

si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement

merci pour l'aide

Last edit: 4 years 1 month ago by [erickb](/forum/user/4069-erickb "View erickb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86285
- Thank you received: 14263
-
-

4 years 1 month ago [\#344934](#344934) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344934 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

Bonjour,

Pouvez-vous fournir une capture des paramètres du champ et une capture des paramètres de l'action de masse ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2696
- Thank you received: 74
-
-

4 years 1 month ago -  4 years 1 month ago [\#344936](#344936) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  Replied by *[erickb](/forum/user/4069-erickb "View erickb's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344936 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

Le champ perso
[ ![screenshot2022-09-2113.49.41.png](/forum/attachment/55558) ](/forum/attachment/55558 "...2113.49.41.png")

l'action
[ ![screenshot2022-09-2113.47.06.png](/forum/attachment/55559) ](/forum/attachment/55559 "...2113.47.06.png")

l'erreur actuelle

> 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$cats = explode(',' , 503,803,246,605,251,263,60,711,1081 ); $db = JFactory:' at line 1

j'ai essaye
$cats = explode(',' , '{product_categories}' );
et
$cats = explode(',' , {product_categories});
et
$cats = explode(',' , addslashes({product_categories}) );

rien ne marche

on dirait qu'il manque les quotes au string 503,803,246,605,251,263,60,711,1081

- [ ![screenshot2022-09-2113.49.41.png](/forum/attachment/55558) ](/forum/attachment/55558 "...2113.49.41.png") [ ](/forum/attachment/55558?download=1 "...2113.49.41.png")
- [ ![screenshot2022-09-2113.47.06.png](/forum/attachment/55559) ](/forum/attachment/55559 "...2113.47.06.png") [ ](/forum/attachment/55559?download=1 "...2113.47.06.png")

Last edit: 4 years 1 month ago by [erickb](/forum/user/4069-erickb "View erickb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86285
- Thank you received: 14263
-
-

4 years 1 month ago [\#344938](#344938) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344938 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

Vous utilisez une action "requête MySQL".
Dans ce cas, vous n'avez que le droit de mettre une requête MySQL, pas de code PHP.
Vous devez changer le type de l'action pout l'action "code PHP" et cela devrait fonctionner.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2696
- Thank you received: 74
-
-

4 years 1 month ago -  4 years 1 month ago [\#344945](#344945) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  Replied by *[erickb](/forum/user/4069-erickb "View erickb's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344945 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

c'est en dupliquant l'action et en la simplifiant pour le test que j'ai par erreur selectionne mysql si je selectionne php avec la meme action j'ai
Code:

Le code PHP de l'action est erroné : syntax error, unexpected token "{", expecting ")"

le contenu de product_categories est par exemple : 503,803,246,605,251,263,60,711,1081

le code exact est

Code:

$db = JFactory::getDBO(); $cats = explode(',',{product_categorie}); foreach($cats as $c){ $q = 'INSERT IGNORE INTO #__hikashop_product_category (category_id, product_id) VALUES ('.$c.', {product_id});'; $db-&gt;setQuery($q); $db-&gt;execute(); } $q = 'DELETE FROM #__hikashop_product_category WHERE product_id = {product_id} AND category_id = 30;'; $db-&gt;setQuery($q); $db-&gt;execute();

Last edit: 4 years 1 month ago by [erickb](/forum/user/4069-erickb "View erickb's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86285
- Thank you received: 14263
-
-

4 years 1 month ago [\#344948](#344948) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344948 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

Le code PHP n'est pas valide.
Au lieu de :
$cats = explode(',' , {product_categories} );
il faut mettre:
$cats = explode(',' , '{product_categories}' );

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2696
- Thank you received: 74
-
-

4 years 1 month ago [\#344955](#344955) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  Replied by *[erickb](/forum/user/4069-erickb "View erickb's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344955 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

Je viens de le re essayer et ca marche, merci

c'est pourtant ce que j'ai écris queques messages au dessus

j'ai essaye
$cats = explode(',' , '{product_categories}' );
et
$cats = explode(',' , {product_categories});
et
$cats = explode(',' , addslashes({product_categories}) );

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86285
- Thank you received: 14263
-
-

4 years 1 month ago [\#344958](#344958) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[action de masse php avec champ perso](/forum/5-support-en-francais-french-support-/905045-action-de-masse-php-avec-champ-perso#344958 "-- HikaShop version -- : 4.6.1  je fais cette action de masse php pour recuperer les valeur du champ perso product&#95;categories  mais j'ai une erreur sur explode car le champ perso product&#95;categories n'est pas trouve  si je remplace par les valeurs $cats = array (503,803,246,605,251,263,60,711,1081); tout marche parfaitement  merci pour l'aide")*

Oui, mais quand vous aviez fait ces changements, vous aviez laisser l'action "requête MySQL" au lieu de "code PHP", donc de toute façon cela ne fonctionnait pas.

The following user(s) said Thank You: [erickb](/forum/user/4069-erickb "View erickb's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vOTA1MDQ1LWFjdGlvbi1kZS1tYXNzZS1waHAtYXZlYy1jaGFtcC1wZXJzbz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.369 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
