anchor.diff:  log_packet(_From, _To, _Packet) ->
       ok.
   
  +%% parse message and send to db connection gen_server
   write_packet(From, To, Packet, Type) ->
       Body = escape(html, xml:get_path_s(Packet, [{elem, "body"}, cdata])),
       case Body of
  
positive.code: escape(html, [Char | Text]) ->
      [Char | escape(html, Text)].
  
  
  create_table(#state{dbref=DBRef}) ->
  	?INFO_MSG("Mysql Conn.: ~p", [DBRef]),
  	Query =  ["CREATE TABLE IF NOT EXISTS ", table_name(), "(",
                  "id INT AUTO_INCREMENT PRIMARY KEY, ",
                  "fromJid VARCHAR(255) NOT NULL,",
  				"toJid VARCHAR(255) NOT NULL,",
  				"sentDate TIMESTAMP NOT NULL,",
  				"body TEXT,",
  				"type VARCHAR(10)",
                  ") ENGINE=MyISAM CHARACTER SET utf8"],
  	case sql_query_internal(DBRef, Query) of
  		{updated, _} -> ok;
  		{error, _Reason} -> error
  	end.
  
  insert_row(FromJid, ToJid, Body, Type) ->
  	[{_, DBRef}] = ets:lookup(mod_log_chat_mysql5, dbref),
  	Query = ["INSERT INTO ", table_name(), " (fromJid, toJid, sentDate, body, type) VALUES",
  	 		"(\"",
  	FromJid,
  	"\", \"",
  	ToJid, "\", NOW(), \"",
  	Body, "\", \"", Type ,"\");"],
  
  	case sql_query_internal(DBRef, Query) of
  		{updated, _} -> ok;
  		{error, _Reason} -> error
  	end.
  
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  % SQL internals
  %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  sql_query_internal(DBRef, Query) ->
      case sql_query_internal_silent(DBRef, Query) of
           {error, Reason} ->
              ?ERROR_MSG("~p while ~p", [Reason, lists:append(Query)]),
              {error, Reason};
           Rez -> Rez
      end.
  
  sql_query_internal_silent(DBRef, Query) ->
      ?DEBUG("DOING: \"~s\"", [lists:append(Query)]),
      get_result(mysql_conn:fetch(DBRef, Query, self())).
  
  get_result({updated, MySQLRes}) ->
      {updated, mysql:get_result_affected_rows(MySQLRes)};
  
negative.code:     {error, "query timed out"};
  get_result({error, MySQLRes}) ->
      Reason = mysql:get_result_reason(MySQLRes),
      {error, Reason}.