Jump to content

Recommended Posts

Posted (edited)

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
  • 3 weeks later...
Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...