General error: 1366 Incorrect integer value ( QUERY EXEPTION )

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

im trying to add some data in the database from a form but i got an exeption : SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '[{"ID_ARTICLE":58}]' for column 'ID_ARTICLE' at row 1 (SQL: insert into annonce (TITRE_ANNONCETYPE_ANNONCEPRIXID_ARTICLE) values (titre, 1, 100, [{"ID_ARTICLE":58}]))

which mean i cant insert the ID_ARTICLE which is an integer here is my query :

public function store(Request $request) { $annonce = new annonce;

    $IDARTICLE = DB::table('article')
        ->select('ID_ARTICLE')
        ->where('NOM_ARTICLE', $request->NOM_ARTICLE)
        ->get();


    $annonce->TITRE_ANNONCE = $request->TITRE_ANNONCE;
    $annonce->TYPE_ANNONCE = $request->TYPE_ANNONCE;
    $annonce->PRIX = $request->PRIX;
    $annonce->ID_ARTICLE = $IDARTICLE;
    $annonce->save();

    return ($annonce);
}

i tried to replace $annonce->ID_ARTICLE = $IDARTICLE; with $annonce->ID_ARTICLE = $IDARTICLE->ID_ARTICLE; to retrieve the integer value from the list but shows another error : Property [ID_ARTICLE] does not exist on this collection instance.

0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Q

Struggling to grow your email list in 2025? Tried these proven hacks yet?

Digital Marketing 0 Answers
Q

What if losing weight could be as easy as sipping delicious smoothies every day?

Health 0 Answers