Welcome Guest, Not a member yet? Register   Sign In
Parse error: syntax error, unexpected T_OBJECT_OPERATOR $this-db->update
#1

[eluser]darian311[/eluser]
Attempted call:
example.com/CodeIgniter/index.php/dbexample/update_user?fb_id=1001&cash=33&coins=22&villagestate=crack

Got

ERROR MESSAGE:

Quote:Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/darhic/labs.villagethegame.com/CodeIgniter/application/controllers/dbexample.php on line 36
Offending line:
Code:
$this-db->update('villagegame', $_GET);
All the other functions on this controller work fine. Any ideas what's wrong with line above?
-Darian

SOURCE:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Dbexample extends CI_Controller{

public function dbexample(){
   parent::__construct();
   echo("Get's type:" . gettype($_GET));

}

public function index(){
  $this->load->database();
  $query = $this->db->query('SELECT fb_id, cash, coins FROM villagegame');

  foreach ($query->result() as $row)
  {
      echo $row->fb_id;
      echo $row->coins;
      echo $row->cash;
  }
  
  echo 'Total Results: ' . $query->num_rows();
}

public function add_user(){
  $this->db->insert('villagegame', $_GET);
}

public function delete_user(){
  $this->db->delete('villagegame', $_GET);
}

public function update_user(){
  $this->db->where('fb_id', $_GET['fb_id']);
  unset($_GET['fb_id']);
  $this-db->update('villagegame', $_GET);
  
  
}


}


?>
#2

[eluser]CroNiX[/eluser]
Look closely at your offending line again. But besides that, what you are doing is crazy with no validation at all.
#3

[eluser]darian311[/eluser]
Thanks for the quick response. didn't see missing > until just now. Smile I'll be researching libs for input validation later. Got recommendations?




Theme © iAndrew 2016 - Forum software by © MyBB