• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse error: syntax error, unexpected T_VARIABLE in D:wampwwwCodeIgniter_2.1.0applicationcontrollerschat.php on line 90

#1
[eluser][email protected][/eluser]
<?php


class chat extends CI_controller

{
function chat()
{
parent::__construct();

$this->load->model('chat_model');
}

function index()
{

$this->view_data['chat_id'] = 1;

if(! $this->session->userdata('logged_in')) {

redirect('user/login');
}

$this->view_data['user_id'] = $this->session->userdata('user_id');

$this->this->session->set_userdata('last_chat_message_id_'. chat_id, 0);

$this->view_data['page_title'] = 'chatting a web base chat app';

$this->view_data['page_content'] = 'view_chat';

$this->load_view('view_main', $this->view_data);


function ajax_add_chat_message()
{


/*thing that need to be past'ed to this function
*
*
*chat_id
*user_id
*chat_message_content
*
*
*
*
*/
$chat_id=$this->input->post('chat_id');

$user_id=$this->input->post('user_id');

$chat_message_contant=$this->input->post('chat_id', TRUE);

$this->chat_model->add_chat_message_content($chat_id, $user_id, $chat_message_content);

echo $this->_get_chat_messages($chat_id);
}
function ajax_get_chat_messages()
{
$chat_id = $this->input->post('chat_id');

echo $this->_get_chat_messages($chat_id);



function _get_chat_messages()

//(int)last_chat_message_id = $this->session-> userdata ('last_chat_message_id_' . $chat_id);
{
$chat_message = $this->chat_model->get_chat_message('$chat_id, $last_chat_message_id');

if ($chat_messages->num_rows()> 0)

//store the last message id

$last_chat_message_id = $chat_messages->row(- 1)->chat_message_id;

$this->this->session->set_userdata('last_chat_message_id_'. chat_id, $last_chat_message_id);

//we have some chat let's return it

$chat_messages_html = '<ul>';

foreach ($chat_messages->result() as $chat_message)

$li_class = ($this->swssion->userdata('user_id') == $chat_message->user_id) ? 'class="by_curreent_deta"' : '';

$chat_messages_html .= '<li' . $li_class . '>' . '<span class="chat_message_header">' . $chat_message->chat_message_timestamp. ' by ' $chat_message->name . '</span><p.class="message_content">' . $chat_message->chat_messge_content . '</p></li>';

$chat_messages_html .= '</ul>';

$result = array('status' => 'ok', 'content'=> $chat_messages_html);

return json_encode($result);

exit();
}
else{
//there was an error do something

$result = array('status' => 'ok', 'content' => '');

return json_encode($result);

exit();
}

}

?&gt;

#2
[eluser]WanWizard[/eluser]
Did you check it yourself? Do you think this is going to work?
Code:
function _get_chat_messages()

(int)last_chat_message_id = $this->session-> userdata ('last_chat_message_id_' . $chat_id);
{
  $chat_message = $this->chat_model->get_chat_message('$chat_id, $last_chat_message_id');

  if ($chat_messages->num_rows()> 0)
...

And I don't think this is going to work either
Code:
$this->this->session->set_userdata...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.