PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 24, 2022

[FIXED] Laravel Array to string conversion error while updating database

 January 24, 2022     laravel, laravel-5     No comments   

Issue

I want to update a totcosty field in the User table but it is throwing this error everytime and it is not updating the field

this is the function for execution:

public static function cost(){
  $user = User::find($user_id);
  $total = Helper::totcost();
  // dd($tot_amt);
  $user->totcosty = $total;
  $user->save(); 
}

Solution

array to string means you are sending an array to the database but db will not accept it you have to explode() the array before sending it to db... Hope it will help!



Answered By - void
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing