Welcome Guest, Not a member yet? Register   Sign In
Change the status in the db
#1

Hello, 



I am a beginner with Codeigniter.
I want to change the status of my comments in order to validate them.
Let me explain: by default comments have a value of 0 and invisible to visitors.
I created an administrator space to manage comments.

I want to change the status from 0 to 1 simply.

I tried this: 

PHP Code:
this-> db-> where ('comment_id', $ comment_id);

This-> db-> update ('status''1');
This-> save (); 


I have a mistake:

Quote:Error Number: 1064

Syntax error near '1 =' 'WHERE `id_commentaire` =' 24 '' in line 1

UPDATE `status` SET 1 = '' WHERE` id_commentaire` = '24'

Filename: C: /wamp64/www/codeIgniter2/system/database/DB_driver.php

Line Number: 691


Thank you in advance for your answers

See you soon
Reply
#2

(06-09-2017, 08:42 AM)tonny16 Wrote: Hello, 



I am a beginner with Codeigniter.
I want to change the status of my comments in order to validate them.
Let me explain: by default comments have a value of 0 and invisible to visitors.
I created an administrator space to manage comments.

I want to change the status from 0 to 1 simply.

I tried this: 

PHP Code:
this-> db-> where ('comment_id', $ comment_id);

This-> db-> update ('status''1');
This-> save (); 


I have a mistake:

Quote:Error Number: 1064

Syntax error near '1 =' 'WHERE `id_commentaire` =' 24 '' in line 1

UPDATE `status` SET 1 = '' WHERE` id_commentaire` = '24'

Filename: C: /wamp64/www/codeIgniter2/system/database/DB_driver.php

Line Number: 691


Thank you in advance for your answers

See you soon

update to 3
PHP Code:
$data = array(
 
   'status' => 1
);

$this->db->where('comment_id'$comment_id);
$this->db->update('mytable'$data); 
Reply
#3

A big thank-you. It was so simple, I'm ashamed ...
Reply




Theme © iAndrew 2016 - Forum software by © MyBB