Hello, Daniweb members. I've been watching your community forever, and I finally decided to join it.

I am currently designing a bot that can talk to users intelligently. The only issue I am having right now is creating a chat log for my members. I need to be able to call a string inside itself and add to it to keep a steady for. Code example below.


Is this possible? I am only getting the second part of the string. It replaces itself instead of just adding to it.

Thank you in advance,


Yes, this is possible.

I think you could write your variable initialization in loop . thats why your string variable is re-initialized..

try this:

// your loop starts here

or post required code ..

Member Avatar
$chatlog .= $currentchat; //$currentchat appended

Sorry simult. post

I seem to be having the same problem with the above methods.

It just works with one chat, and clears it out each time.

Thank you for the replies,


I believe the error is because the page is refreshing and not storing the variables.

A good way to test it is simply by printing out the variable to make sure they are what you think.


echo "Current Chat: " . $currentchat ."<br />";
echo "Chatlog before: " . $chatlog  ."<br />";
$chatlog .= $currentchat;
echo "Chatlog after: " . $chatlog ."<br />";
Member Avatar

If you are refreshing the page, place the variable in a session:

  $chatlog = $_SESSION['chatlog'];
  $chatlog = "";
..rest of code...

$chatlog .= $currentchat;
$_SESSION['chatlog'] = $chatlog;

I actually developed my own session code.

Thank you guys for all the help.

Member Avatar

Good. Mark it solved then.