Help with an error in PHPMyChat On FireFox

Hello,

I was wondering if anyone can help me fix an error for PHPMyChat. The error happens in FireFox, it works fine in IE but many of my users use FireFox and many users are switching to FireFox.

The error is this:
Parse error: syntax error, unexpected T_CASE in /home/bestpre/public_html/chats/druw/messagesL.php3 on line 119

If any one could help me please I would greatly Appreciate it.

The code is this:

[code]<?php
// Get the names and values for vars sent by index.lib.php3
if (isset($HTTP_GET_VARS))
{
while(list($name,$value) = each($HTTP_GET_VARS))
{
$$name = $value;
};
};

// Fix a security hole
if (isset($L) && !is_dir(’./localization/’.$L)) exit();

require("./config/config.lib.php3");
require("./localization/".$L."/localized.chat.php3");
require("./lib/database/".C_DB_TYPE.".lib.php3");
require("./lib/clean.lib.php3");

// Special cache instructions for IE5+
$CachePlus = “”;
if (ereg(“MSIE [56789]”, (isset($HTTP_USER_AGENT)) ? $HTTP_USER_AGENT : getenv(“HTTP_USER_AGENT”))) $CachePlus = “, pre-check=0, post-check=0, max-age=0”;
$now = gmdate(‘D, d M Y H:i:s’) . ’ GMT’;

header(“Expires: $now”);
header(“Last-Modified: $now”);
header(“Cache-Control: no-cache, must-revalidate”.$CachePlus);
header(“Pragma: no-cache”);

header(“Content-Type: text/html; charset=${Charset}”);

// Avoid server configuration for magic quotes
set_magic_quotes_runtime(0);

// Translate to html special characters, and entities if message was sent with a latin 1 charset
$Latin1 = ($Charset == “iso-8859-1”);
function special_char($str,$lang,$slash_on)
{
$str = ($lang ? htmlentities(stripslashes($str)) : htmlspecialchars(stripslashes($str)));
return ($slash_on ? addslashes($str) : $str);
};

$DbLink = new DB;

// ** Updates user info in connected users tables **
$DbLink->query(“SELECT room,status FROM “.C_USR_TBL.” WHERE username = ‘$U’ LIMIT 1”);
if($DbLink->num_rows() != 0)
{
// There is a row for the user in the users table
list($room,$status) = $DbLink->next_record();
$DbLink->clean_results();
$kicked = 0;
if ($room != stripslashes($R)) // Same nick in another room
{
$DbLink->query(“INSERT INTO “.C_MSG_TBL.” VALUES ($T, ‘$R’, ‘SYS exit’, ‘’, “.time().”, ‘’, 'sprintf(L_EXIT_ROM, “”.special_char($U,$Latin1,1).”")’)");
$kicked = 3;
}
elseif ($status == “k”) // Kicked by a moderator or the admin.
{
$DbLink->query(“INSERT INTO “.C_MSG_TBL.” VALUES ($T, ‘$R’, ‘SYS exit’, ‘’, “.time().”, ‘’, 'sprintf(L_KICKED, “”.special_char($U,$Latin1,1).”")’)");
$kicked = 1;
}
elseif ($status == “d”) // The admin just deleted the room
{
$kicked = 2;
}
elseif ($status == “b”) // Banished by a moderator or the admin.
{
$DbLink->query(“INSERT INTO “.C_MSG_TBL.” VALUES ($T, ‘$R’, ‘SYS exit’, ‘’, “.time().”, ‘’, 'sprintf(L_BANISHED, “”.special_char($U,$Latin1,1).”")’)");
$kicked = 4;
};
if ($kicked > 0)
{
// Kick the user from the current room
?>

<?php
$DbLink->close();
exit;
};
// Updates the time to ensure the user won’t be cleaned from the users table
$DbLink->query(“UPDATE “.C_USR_TBL.” SET u_time = “.time().” WHERE room = ‘$R’ AND username = ‘$U’”);
}
else
{
// User hasn’t been found in the users table -> add a row
$DbLink->clean_results();
$DbLink->query(“SELECT perms,rooms FROM “.C_REG_TBL.” WHERE username=’$U’ LIMIT 1”);
$reguser = ($DbLink->num_rows() != 0);
if ($reguser) list($perms, $rooms) = $DbLink->next_record();
$DbLink->clean_results();
// Get user status
$status = “u”;
if ($reguser)
{
switch ($perms)
{
case ‘admin’:
$status = “a”;
break;
case ‘admin’:
$status = “o”;
break;
case ‘moderator’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “m”;
break;
case ‘fmod’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “f”;
break;
case ‘supermod’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “s”;
break;
};
};
default:
$status = “r”;
};
};
// Get IP address
include("./lib/get_IP.lib.php3"); // Set the $IP var
$DbLink->query(“INSERT INTO “.C_USR_TBL.” VALUES (’$R’, ‘$U’, ‘$Latin1’, “.time().”, ‘$status’, ‘$IP’)”);
};

// Text direction
$textDirection = ($Charset == “windows-1256”) ? “RTL” : “LTR”;

// For translations with an explicit charset (not the ‘x-user-defined’ one)
if (!isset($FontName)) $FontName = “”;
?>

Messages frame <?php if ($D > 0) echo(''); ?> " TYPE="text/css"> > <?php

// ** Get messages **

// Define the SQL query (depends on values for ignored users list and on whether to display
// notification messages or not)

$CondForQuery = “”;
$IgnoreList = “”;
if (isset($Ign)) $IgnoreList = “’”.str_replace(",","’,’",addslashes(urldecode($Ign)))."’";
if ($NT == “0”) $IgnoreList .= ($IgnoreList != “” ? “,”:"")."‘SYS enter’,‘SYS exit’";
if ($IgnoreList != “”) $CondForQuery = "username NOT IN (${IgnoreList}) AND ";
$CondForQuery .= “(address = ’ *’ OR (address = ‘$U’ AND (room = ‘$R’ OR username = ‘SYS inviteTo’)) OR (room = ‘$R’ AND (address = ‘’ OR username = ‘$U’)))”;

$DbLink->query(“SELECT m_time, username, latin1, address, message FROM “.C_MSG_TBL.” WHERE “.$CondForQuery.” ORDER BY m_time DESC LIMIT $N”);

// Format and display new messages
if($DbLink->num_rows() > 0)
{
$i = “1”;
$today = date(‘j’, time() + C_TMZ_OFFSET6060);
$MessagesString = “”;
while(list($Time, $User, $Latin1, $Dest, $Message) = $DbLink->next_record())
{
// Skip the oldest message if the day seperator has been added
if (isset($day_separator) && $i == $N) continue;

    $NewMsg = "<P CLASS="msg">";
    if ($ST == 1) $NewMsg .= "<SPAN CLASS="time">".date("H:i:s", $Time +  C_TMZ_OFFSET*60*60)."</SPAN> ";

    // "Standard" messages
    if (substr($User,0,4) != "SYS ")
    {
        $User = "<A HREF="#" onClick="window.parent.userClick('".special_char($User,$Latin1,1)."',true); return false" CLASS="sender">".special_char($User,$Latin1,0)."</A>";
        if ($Dest != "") $Dest = "]<BDO dir="${textDirection}"></BDO>>[".htmlspecialchars(stripslashes($Dest));
        $NewMsg .= "<B>[${User}${Dest}]<BDO dir="${textDirection}"></BDO></B> $Message</P>";
    }
    // "System" messages
    else
    {
        if ($Dest == " *")
        {
            $Message = "[".L_ANNOUNCE."]<BDO dir="${textDirection}"></BDO> ".$Message;
        }
        else
        {
            if ($Dest != "") $NewMsg .= "<B><BDO dir="${textDirection}"></BDO>>[".htmlspecialchars(stripslashes($Dest))."]<BDO dir="${textDirection}"></BDO></B> ";
            $Message = str_replace("$","\$",$Message);    // avoid '$' chars in nick to be parsed bellow
            eval("$Message = $Message;");
        };
        $NewMsg .= "<SPAN CLASS="notify">".$Message."</SPAN></P>";
    };

    // Separator between messages sent before today and other ones
    if (!isset($day_separator) && date("j", $Time +  C_TMZ_OFFSET*60*60) != $today)
    {
        $day_separator = "<P CLASS="msg"><SPAN CLASS="notify">--------- ".($O == 0 ? L_TODAY_UP : L_TODAY_DWN)." ---------</SPAN></P>";
    };

    if($O == 0) {
        $MessagesString .= ((isset($day_separator) && $day_separator != "") ? $day_separator."n" : "").$NewMsg."n";
    } else {
        $MessagesString = $NewMsg.((isset($day_separator) && $day_separator != "") ? "n".$day_separator : "")."n".$MessagesString;
    };
    
    if (isset($day_separator)) $day_separator = "";        // Today separator already printed
    $i++;
};
echo($MessagesString);

}
else
{
echo("".L_NO_MSG."");
};

$DbLink->clean_results();
$DbLink->close();
?>

[/code] Thanks, Corey

What exactly have you done to resolve this?

Which line (specifically) is 119?

does the error actually stop the script from running or does it just present the error (in an inconvenient location)?

PHP is serverside, so it shouldn’t matter whether the user views the page in IE, FF, Opera or Safari (I guess Lynx would pose a problem), but I’ve heard of problems with IE-FF differences.

As far as I know: a parse error is fatal (so it actually kills the script), but you’re gonna have to confirm this.

As far as your problem goes: you’re not closing some of the opening brackets for your conditional statements. PHP doesn’t like that, not in IE and not in FF.

On a sidenote: I noticed that your file extension is php3. Why are you still using PHP3 (if you are)?

Its a phpmychat. The file works fine in IE just not FF. I fixed the error now The messages show up at top and they should show up at the bottom. Anyone wanna help?

A live link is: http://chats.phpchathost.com/TestZone/
Ignore the index page, it’s just a test chat.

The problem was:

case 'fmod': $roomsTab = explode(",",$rooms); for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab)) { if (strcasecmp(stripslashes($R), $room_name) == 0) { $status = "f"; break;

I fixed this now Doing:

[code]case ‘fmod’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “f”;
}
}

break;[/code]

The full source is:

[code]<?php
// Get the names and values for vars sent by index.lib.php3
if (isset($HTTP_GET_VARS))
{
while(list($name,$value) = each($HTTP_GET_VARS))
{
$$name = $value;
};
};

require("./${ChatPath}config/config.lib.php3");
require("./${ChatPath}localization/".$L."/localized.chat.php3");
require("./${ChatPath}lib/database/".C_DB_TYPE.".lib.php3");
require("./${ChatPath}lib/clean.lib.php3");

// Special cache instructions for IE5+
$CachePlus = “”;
if (ereg(“MSIE [56789]”, (isset($HTTP_USER_AGENT)) ? $HTTP_USER_AGENT : getenv(“HTTP_USER_AGENT”))) $CachePlus = “, pre-check=0, post-check=0, max-age=0”;
$now = gmdate(‘D, d M Y H:i:s’) . ’ GMT’;

header(“Expires: $now”);
header(“Last-Modified: $now”);
header(“Cache-Control: no-cache, must-revalidate”.$CachePlus);
header(“Pragma: no-cache”);

header(“Content-Type: text/html; charset=${Charset}”);

// Avoid server configuration for magic quotes
set_magic_quotes_runtime(0);

// Translate to html special characters, and entities if message was sent with a latin 1 charset
$Latin1 = ($Charset == “iso-8859-1”);
function special_char($str,$lang,$slash_on)
{
$str = ($lang ? htmlentities(stripslashes($str)) : htmlspecialchars(stripslashes($str)));
return ($slash_on ? addslashes($str) : $str);
};

$DbLink = new DB;

// ** Updates user info in connected users tables **
$DbLink->query(“SELECT room,status FROM “.C_USR_TBL.” WHERE username = ‘$U’ LIMIT 1”);
if($DbLink->num_rows() != 0)
{
// There is a row for the user in the users table
list($room,$status) = $DbLink->next_record();
$DbLink->clean_results();
$kicked = 0;
if ($room != stripslashes($R)) // Same nick in another room
{
$DbLink->query(“INSERT INTO “.C_MSG_TBL.” VALUES ($T, ‘$R’, ‘SYS exit’, ‘’, “.time().”, ‘’, 'sprintf(L_EXIT_ROM, “”.special_char($U,$Latin1,1).”")’)");
$kicked = 3;
}
elseif ($status == “k”) // Kicked by a moderator or the admin.
{
$DbLink->query(“INSERT INTO “.C_MSG_TBL.” VALUES ($T, ‘$R’, ‘SYS exit’, ‘’, “.time().”, ‘’, 'sprintf(L_KICKED, “”.special_char($U,$Latin1,1).”")’)");
$kicked = 1;
}
elseif ($status == “d”) // The admin just deleted the room
{
$kicked = 2;
}
elseif ($status == “b”) // Banished by a moderator or the admin.
{
$DbLink->query(“INSERT INTO “.C_MSG_TBL.” VALUES ($T, ‘$R’, ‘SYS exit’, ‘’, “.time().”, ‘’, 'sprintf(L_BANISHED, “”.special_char($U,$Latin1,1).”")’)");
$kicked = 4;
};
if ($kicked > 0)
{
// Kick the user from the current room
?>

<?php
$DbLink->close();
exit;
};
// Updates the time to ensure the user won’t be cleaned from the users table
$DbLink->query(“UPDATE “.C_USR_TBL.” SET u_time = “.time().” WHERE room = ‘$R’ AND username = ‘$U’”);
}
else
{
// User hasn’t been found in the users table -> add a row
$DbLink->clean_results();
$DbLink->query(“SELECT perms,rooms FROM “.C_REG_TBL.” WHERE username=’$U’ LIMIT 1”);
$reguser = ($DbLink->num_rows() != 0);
if ($reguser) list($perms, $rooms) = $DbLink->next_record();
$DbLink->clean_results();
// Get user status
$status = “u”;
if ($reguser)
{
switch ($perms)
{
case ‘admin’:
$status = “a”;
break;
case ‘admin’:
$status = “o”;
break;
case ‘moderator’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “m”;
}
}
break;
case ‘fmod’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “f”;
}
}

break;
case ‘supermod’:
$roomsTab = explode(",",$rooms);
for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab))
{
if (strcasecmp(stripslashes($R), $room_name) == 0)
{
$status = “s”;
break;
};
};
default:
$status = “r”;
};
};
// Get IP address
include("./lib/get_IP.lib.php3"); // Set the $IP var
$DbLink->query(“INSERT INTO “.C_USR_TBL.” VALUES (’$R’, ‘$U’, ‘$Latin1’, “.time().”, ‘$status’, ‘$IP’)”);
};

// Text direction
$textDirection = ($Charset == “windows-1256”) ? “RTL” : “LTR”;

// For translations with an explicit charset (not the ‘x-user-defined’ one)
if (!isset($FontName)) $FontName = “”;
?>

Messages frame <?php if ($D > 0) echo(''); ?> " TYPE="text/css"> > <?php

// ** Get messages **

// Define the SQL query (depends on values for ignored users list and on whether to display
// notification messages or not)

$CondForQuery = “”;
$IgnoreList = “”;
if (isset($Ign)) $IgnoreList = “’”.str_replace(",","’,’",addslashes(urldecode($Ign)))."’";
if ($NT == “0”) $IgnoreList .= ($IgnoreList != “” ? “,”:"")."‘SYS enter’,‘SYS exit’";
if ($IgnoreList != “”) $CondForQuery = "username NOT IN (${IgnoreList}) AND ";
$CondForQuery .= “(address = ’ *’ OR (address = ‘$U’ AND (room = ‘$R’ OR username = ‘SYS inviteTo’)) OR (room = ‘$R’ AND (address = ‘’ OR username = ‘$U’)))”;

$DbLink->query(“SELECT m_time, username, latin1, address, message FROM “.C_MSG_TBL.” WHERE “.$CondForQuery.” ORDER BY m_time DESC LIMIT $N”);

// Format and display new messages
if($DbLink->num_rows() > 0)
{
$i = “1”;
$today = date(‘j’, time() + C_TMZ_OFFSET6060);
$MessagesString = “”;
while(list($Time, $User, $Latin1, $Dest, $Message) = $DbLink->next_record())
{
// Skip the oldest message if the day seperator has been added
if (isset($day_separator) && $i == $N) continue;

	$NewMsg = "<P CLASS="msg">";
	if ($ST == 1) $NewMsg .= "<SPAN CLASS="time">".date("H:i:s", $Time +  C_TMZ_OFFSET*60*60)."</SPAN> ";

	// "Standard" messages
	if (substr($User,0,4) != "SYS ")
	{
		$User = "<A HREF="#" onClick="window.parent.userClick('".special_char($User,$Latin1,1)."',true); return false" CLASS="sender">".special_char($User,$Latin1,0)."</A>";
		if ($Dest != "") $Dest = "]<BDO dir="${textDirection}"></BDO>>[".htmlspecialchars(stripslashes($Dest));
		$NewMsg .= "<B>[${User}${Dest}]<BDO dir="${textDirection}"></BDO></B> $Message</P>";
	}
	// "System" messages
	else
	{
		if ($Dest == " *")
		{
			$Message = "[".L_ANNOUNCE."]<BDO dir="${textDirection}"></BDO> ".$Message;
		}
		else
		{
			if ($Dest != "") $NewMsg .= "<B><BDO dir="${textDirection}"></BDO>>[".htmlspecialchars(stripslashes($Dest))."]<BDO dir="${textDirection}"></BDO></B> ";
			$Message = str_replace("$","\$",$Message);	// avoid '$' chars in nick to be parsed bellow
			eval("$Message = $Message;");
		};
		$NewMsg .= "<SPAN CLASS="notify">".$Message."</SPAN></P>";
	};

	// Separator between messages sent before today and other ones
	if (!isset($day_separator) && date("j", $Time +  C_TMZ_OFFSET*60*60) != $today)
	{
		$day_separator = "<P CLASS="msg"><SPAN CLASS="notify">--------- ".($O == 0 ? L_TODAY_UP : L_TODAY_DWN)." ---------</SPAN></P>";
	};

	if($O == 0) {
		$MessagesString .= ((isset($day_separator) && $day_separator != "") ? $day_separator."n" : "").$NewMsg."n";
	} else {
		$MessagesString = $NewMsg.((isset($day_separator) && $day_separator != "") ? "n".$day_separator : "")."n".$MessagesString;
	};
	
	if (isset($day_separator)) $day_separator = "";		// Today separator already printed
	$i++;
};
echo($MessagesString);

}
else
{
echo("".L_NO_MSG."");
};

$DbLink->clean_results();
$DbLink->close();
?>

[/code]

I get no error messages I just want to know why they are showing up at the top and not the bottom. They show up at the bottom on IE perfectly.

Thanks,
Corey

We don’t know :slight_smile: Have you contaced the creators of PHPMyChat? I’m sure they know more about PHPMyChat than I do :wink: Have you read their FAQ? The answer might be in there. Does PHPMyChat even support PHP3?

I’m sorry to inform you that we generally don’t offer support on third-party scripts.

More specifically, we don’t necessarily offer support for resolving third party script errors. There is, generally, a development team who works on it and resolves them.

Now if you have a particular modification that you are working on, on that third party script, then we may be able to help. However, again since the developers know their program best, that’s probably the best place to start.

If, however, you still desire help here after checking those areas, then please feel free to post here. You should however, make sure you let us know what you have tried and provide relevant code snippets. The more detail (of RELEVANT information), the better.

This is still no guarantee that you will get favorable responses, but it might help.

Sponsor our Newsletter | Privacy Policy | Terms of Service