News:

Wondering if this will always be free?  See why free is better.

Main Menu

MySQL UPDATE statement with $smcFunc['db_query']

Started by Decent_946, June 04, 2020, 08:29:16 AM

Previous topic - Next topic

Decent_946

Hey folks,

Was wondering in manuals and mods script to find somewhere MySQL UPDATE Statement via SMF Database Functions ($smcFunc) but I couldn't figure out. Seems like nobody is using it. Is there any function to update data in a column or otherwise, can I use MySQL UPDATE statement in db_query? I want to store user_ids in same cell instead of creating new entry for each user.

I'm using this code but it's giving some error.


$request = $smcFunc['db_query']('',
            'UPDATAE {db_prefix}v_reactions SET members_id = CONCAT_WS(",",members_id,{int:id_member}), no_of_reacts = {int:reacts} ',
            array(
                'id_member' => $member_id,
                'reacts' => ++$no_of_reacts,  //error line no: 41
            )
        );



the error
QuoteDatabase Error
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATAE `id13123390_tvpsmf`.stp_v_reactions SET members_id = CONCAT_WS(",",membe' at line 1
File: /storage/ssd1/390/13123390/public_html/forum/dothis.php
Line: 41
another point to note, I'm using MySQL but the error says MariaDB. I faced a similar error before on db_create_table which was solved by correcting the type to text instead of varchar. It also mentioned MariaDB instead of MySQL.

Let me know if you need to know something else.

Thank you! :)
Thankx to RebellioN

Arantor


Decent_946

Quote from: Arantor on June 04, 2020, 08:35:05 AM
It doesn't say UPDATE, it says UPDATAE...
And I wasted my 2 days thinking what's wrong at line 40. Silly me.

Thanks. Solved. :)
Thankx to RebellioN

Advertisement: