I have very strange problem...It looks like i can't update database ( from textarea field ) when i'm using variable inside query. Sample from model:
This works:
public function update_vendor_about ( $id, $txt )
{
$data = array ( "vendor_about" => $txt, );
$this->db->where("id", $id);
$this->db->update("users", $data);
}
but, this does not work:
public function update_vendor_about ( $id, $txt )
{
$data = array ( "vendor_about" => 'sometext', );
$this->db->where("id", $id);
$this->db->update("users", $data);
}
Call from controller:
$message = $this->input->post('profile_about');
$this->user_model->update_vendor_about ( $active_user_id, $message );
Model gets $txt
OK, i can see it and output it properly. Same thing happens if i write entire UPDATE
query manually.
I think problem could be in actual $txt
content, so i tried with trim()
, stripslashes()
, replacing , etc, but nothing helps...
Any ideas?
Your $txt is key => value array. Specify key when you are accessing array.
$data = array ( "vendor_about" => $txt["vendor_about"] );
$this->db->where("id", $id);
$this->db->update("users", $data);
Seems you missed array index in update query :
$data = array ("vendor_about"=>$txt['vendor_about']);
$this->db->where("id",$id);
$this->db->update("users",$data);
use echo $this->db->last_query(); you will get query and then run it in phpmyadmin or sqlyog and you will get error message and then you can resolve it.
Ok, this issue is server related. I have just tried it on another server with Apache 2.4.9, PHP 5.5.12 and MySQL 5.6.17 - and it works.