Jump to content

php shopping cart oop mvc paypal


Shad76

Recommended Posts

This is the error I keep getting when clicking the add to cart button on the product of choice.
Fatal error: Uncaught Error: [] operator not supported for strings in C:\xampp\htdocs\phpcartoopmvc-projectfiles\app\models\m_products.php:172 Stack trace: #0 C:\xampp\htdocs\phpcartoopmvc-projectfiles\app\models\m_cart.php(162): Products->get_prices(Array) #1 C:\xampp\htdocs\phpcartoopmvc-projectfiles\app\init.php(51): Cart->get_total_cost() #2 C:\xampp\htdocs\phpcartoopmvc-projectfiles\index.php(3): include('C:\\xampp\\htdocs...') #3 {main} thrown in C:\xampp\htdocs\phpcartoopmvc-projectfiles\app\models\m_products.php on line 172

could the constants I have set be part of the problem?

benshop.png

constants.png

Screenshot 2021-07-17 234852.png

Edited by Shad76
showing image of product buttons that cause error
Link to comment
Share on other sites

  • 3 weeks later...

it looks like $data in line 172 is set as a string earlier in the code.  While you do not have to explicitly set data types for most stuff in PHP, IF $data was set to a string value, you cannot then use it as an array in that way.  That line appears to be saying `add a new entry in this array at the end with the value ...` and the array you are setting.

If you are not using $data earlier, then simply get rid of the square brackets after that.

If that doesn't solve it, I might be able to help if I saw more of the code

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...