its the receiver column
ajax,
function sendMessage(str, str2)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="getuser.php";
url=url+"?m="+str;
url=url+"&u="+str2;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
php
<?php
session_start();
if ($_SESSION['loggedIn'] != "true") {
header("Location: default.php");
}
$q=$_GET["q"];
$m = $_GET['m'];
$u = $_GET['u'];
if(isset($q)){
require("conn.php");
if(is_numeric($q)){
$sql="SELECT * FROM members WHERE id = '".$q."'";
}else{
$sql="SELECT * FROM members WHERE username = '".$q."'";
}
$dbdata = mysql_query($sql);
$result = mysql_fetch_array($dbdata);
$newchat = rand(0, 999999);
$_SESSION['chat'] = $newchat;
if($result['online'] == 1){
$u1 = $_SESSION['id'];
$u2 = $result['id'];
echo "This player is online. <a href='chat.php?chatid=".$newchat."&u1=".$u1."&u2=".$u2."'>Start chat</a>.";
}else{
echo "This player is currently offline and you can not chat with them.";
}
}else{
require("conn1.php");
$query = "insert into single_chat(chatid, sender, receiver, message) values ('".$_SESSION['chat']."', '".$_SESSION['id']."', '$u', '$m')";
$dbdata = mysql_query($query) or die (mysql_error());
echo "added succesfully";
}
?>
i cant see why it is inserting into the db as receiver = 0 not what it should be

New Topic/Question
Reply




MultiQuote






|