PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The instant messenger I am setting up is in PHP and connects to a mysql database. It has scripts for login, messaging, and registration. It's supposed to log you out when you close the IM window. It keeps logging people out as soon as they register or login. I figure that the problem has to either be in the im window script or the logout script
<?
include ("mysql.php");
mysql_select_db("swacfans_im");
$query="select * from users where username='$username' and status="yes"";
$result=mysql_query($query, $link);
if($result!=0)
{
print"<center><body bgcolor="000066"><span style=background-color:8080C0><font color=lightblue> $username you have logged out </span>";
exit;
}
else
{
$query="delete from chatdata where message ='<br>' or buddy='to <font color=blue></font>'";
mysql_query($query,$link);
$query="select sender, buddy, message from chatdata where sender = '<font color=red>$username</font>' or sender like '%$buddy%' and
buddy ='<font color=blue>$buddy</font>' or buddy like '%$username%' order by id desc";
echo mysql_error();
if($result!=0)
print"<center><body bgcolor="000066"><span style=background-color:8080C0><font color=lightblue> $username you have logged out </span>";
exit;
It seems to be taking this result no matter what I do.
Yeah it basically was a runtime error. I fixed it by changing it to result==0 insteand of !=0, but now I have to figure out why it's not storing passwords correctly. I can register but when I try to log back in, it tells me, the password is incorrect or the username is in use.