PHP Chat Script - Problem Ajax and variable in php

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
hups
Posts: 7

PHP Chat Script - Problem Ajax and variable in php

I have set the

Code: Select all

$c_subdir = ''.$username.'';//$username comes from database
the chat is looking ok, the entrys come from harry.txt,
The chat with firebug show the right harry.txt and the code looks in browser

Code: Select all

<div data-subdir="harry/" id="chatwindow">
ok that is good .
but when i post entry, the chat post, is not in the text file ??
i take a look in the js the path come from data-subdir, all is ok ,i cant see errors, why is the post not in harry.txt

when i set (write) in $c_subdir = 'harry';
the code look like the same as bevore but chat is not going . i can see the chats bevore the harry.txt is loadet ok.
here little code from setchat, in website(i must set it with Iframe)

Code: Select all

<iframe width="657" height="500" frameborder="0" style="background:#292929" allowtransparency="true" src="http://web-apps.hupsis-e107.de/e107_module/chat/chatfiles/setchat.php?userkey=2999d817f1ea5001303577bcafe11bd3&username=hups" name="shoutbox"></iframe>

Code: Select all

$get_user = $_GET['username'];
session_start();
    $_SESSION['username'] = $get_user;

 define('CHATADD', 0);
if(CHATADD !== 1) {
  if(isset($_SESSION['username'])) define('CHATUSER', $_SESSION['username']);
}
 
 $c_subdir = ''.$username.'';//$username comes from database   
ok i think the mistake is here :

Code: Select all

$query = "SELECT * FROM e107_modul_book  WHERE modul='chat' AND md5userid='".$first_get_value."'";
the setchat is ajax reload but the $first_get_value comes from the side and when side is reload the $first_get_value =0

that is very bad.
why must the setchat load with ajax ??

Admin
I didn't understand well the problem, I not know what "$first_get_value comes from the side" is; but if the problem has to do with the value of the $first_get_value variable, you can keep that value into a $_SESSION, then you use it from session in your $query.
Something like this.

Code: Select all

if(!isset($_SESSION['md5userid'])) $_SESSION['md5userid'] = $first_get_value;
$query = "SELECT * FROM e107_modul_book  WHERE modul='chat' AND md5userid='". $_SESSION['md5userid'] ."'"; 
- The ideea is to keep in session the values that are used in setchat.php but they aren't passed via ajax, and get them from session when is ajax request.

Similar Topics