Jump to content

Syntax error help needed


cobusbo

Recommended Posts

Hi, I had a chat script lying around but wanted to add a login form in case the mxitid wasn't found in the database so I made a few changes to the script to check for records in databases and retrieving the username according the mxit ID. but after I made few changes im getting syntax errors can someone maybe tell me where I made mistakes please.

<?php
// database connection info
$conn = mysql_connect('*******','********','*******') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('************',$conn) or trigger_error("SQL", E_USER_ERROR);

$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con);
$result = mysql_query($query0);
                $myrows = mysql_fetch_array($result);
  if (mysql_num_rows($query0) != 0)
  {
      echo "define('TIMEZONE', 'Africa/Harare');
date_default_timezone_set(TIMEZONE);


echo "<html><br>
<span style="color:red"><b><u>Chat Beta: Errors may apply please send feedback with contact us regarding problems!</u></b></span>
</html>";



// find out how many rows are in the table 
$sql = "SELECT COUNT(*) FROM StringyChat";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 20;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   // cast var as int
   $currentpage = (int) $_GET['currentpage'];
} else {
   // default page num
   $currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
   // set current page to last page
   $currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
   // set current page to first page
   $currentpage = 1;
} // end if

// the offset of the list, based on current page 
$offset = ($currentpage - 1) * $rowsperpage;




    /*
     * StringyChat
     *
	 * Please refer to readme.txt supplied with the StringyChat distribution for information on
	 * installing and configuring. 
	 *
     */





define('TIMEZONE', 'Africa/Harare');
date_default_timezone_set(TIMEZONE);



    include("chat_code_header.php");

    $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); 
    $myrow = mysql_fetch_array($result); 

    $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on
	$install_url = $myrow["install_url"]; // URL to install dir of StringyChat
    $name_size = $myrow["name_size"]; // Maximum size of the name
    $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit.
    $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split.
    $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display.
    $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes
	$email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to

    
	if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) 
    { 
    $StringyChat_name = $_POST['StringyChat_name'];
    $StringyChat_message = $_POST['StringyChat_message'];
    }
	


<div id="StringyChat">


    // Check if visitor's IP is banned.  If so, do not display the form,
    // show a banned IP message instead.

$name = $myrows["Username"];
if(!isset($name))
{
	$name = "SYSOP";
}




    $ip = $_SERVER["REMOTE_ADDR"];
    $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\"";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    if($myrow["ip"] == "") {	// Checks if IP not found in banned list




?>
<html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>">
      <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20">
      <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea>
      <br>
      <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message">
    </form>
</html>

<?

    } else {
      echo "Posting disabled - Your IP has been banned.";
    }
    
    // Should we try to create a post?
    if (isset($StringyChat_name) && isset($StringyChat_message)) {

        // Remove whitespaces and slashes.
        $name = trim(stripslashes($StringyChat_name));
        $message = trim(stripslashes($StringyChat_message));

        
            // Check name and message have been entered.
            if (strlen($name) > 0 && strlen($message) > 0) {
                
                // Limit the size of the fields as per variable defnitions.
                if (strlen($name) > $name_size) {
                    $name = substr($name, 0, $name_size);
                }
                if (strlen($message) > $message_size) {
                    $message = substr($message, 0, $message_size);
                }
                
                // Remove new lines from name.
                $name = str_replace("\n", " ", $name);
                
				// Stripping out \r's so email formattnig appears correctly.
				$message = str_replace("\r", "", $message);
				
				// Create an email-friendly version of the message.
				$message_emailable = str_replace("<br>", "\n", $message);
				$result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db);
                while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) {
	              $the_word = $myrow_wordswap["word"];
                  $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable);
                }

                // Replace the new lines with encoded line breaks for HTML (thanks milahu).
                $message = str_replace("\n", "c#lb", $message);

                // Use HTML encoding on ame and message so database doesn't misinterpret data.
	            $name = htmlentities($name);
                $message = htmlentities($message, ENT_COMPAT);
				
                
                
                // IP address of submitter and time of post.
$ip = $_SERVER["REMOTE_ADDR"];
$name = $_SERVER["HTTP_X_MXIT_NICK"];
$msg = $_POST['StringyChat_message'];
$post_time = date("U");
$mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"];



if(!isset($mxitid))
{
	$mxitid = "DEFAULT";

}
if(!isset($name))
{
	$name = "SYSOP";
}




                // check to see if a duplicate exists
                $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 1800 )";
                $result = mysql_query($sql);
                $myrow = mysql_fetch_array($result);

                if($myrow["StringyChat_message"] == "") {	// Checks if record not matching in db
                  // Save the record
                  $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time)";
                  $result = mysql_query($sql);
				  
			

                } else {
                  echo "Duplicate post detected<br>";
                }                
            }
            else {
                echo "<font color=\"red\">You must Type a message</font><br><br>";
            }

      unset($_POST["StringyChat_name"]);
      unset($_POST["StringyChat_message"]);
      unset($StringyChat_ip);
      unset($StringyChat_name);
      unset($StringyChat_message);
      unset($StringyChat_time);
      unset($mxit_id);

    }
    
// get the info from the db 
$sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);



function filterBadWords($str)
{
	
	
    $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); 
    $replacements = ":-x";
    
    while($row = mysql_fetch_assoc($result1))
    {
          $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str);
    }  
    
    return $str;
}



// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($result)) 
//while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'])
 {
   // echo data
   //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'])
$admin = array('SYSOP','cobusbo');



if (in_array($list['StringyChat_name'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:red">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />' . '<p>';
}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />' . '<p>';
}






}






    // Load up the last few posts.  The number to load is defined by the "ShowPostNum" variable.
    $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db);

    include("sort_widths.php");

    while ($myrow = mysql_fetch_array($result)) {
      $msg = $myrow["StringyChat_message"];
	  
	  // Convert the encoded line break into an actual <br> tag (thanks milahu)
      $msg = str_replace("c#lb", "<br>", $msg);

      // Convert the encoded image tag into a html tag
      $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg);
	  
	  // split the lines
      $msg = htmlwrap($msg, $line_length);

      $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db);
      while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) {
	    $the_word = $myrow_wordswap["word"];
        $msg = ereg_replace($the_word, ":-x",$msg);
      }

   
    }
   ?>     
<?









// end while

/******  build the pagination links ******/
// range of num links to show
$range = 3;

// if not on page 1, don't show back links
if ($currentpage > 1) {
   // show << link to go back to page 1
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
   // get previous page num
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if 

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) {
         // 'highlight' it but don't make a link
         echo " [<b>$x</b>] ";
      // if not current page...
      } else {
         // make it a link
         echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
      } // end else
   } // end if 
} // end for

// if not on last page, show forward and last page links        
if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page 
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
   // echo forward link for lastpage
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/

?><br>
    <html>  <i>Type your Message here...</i>:<br></html>
";
  }

  else
  {
    <html>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
Username:<br>
<input type="text" name="username" ><br>
<input type="hidden" value="<?php echo $_SERVER['HTTP_X_MXIT_LOGIN']; ?>" name"userid" >

<br><br>
<input type="submit" value="Submit">
</form>
</html>

<?
$usernames = $_GET['username'];
$mid = $_GET['userid'];

$sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")";
                  $result = mysql_query($sql0);


?>
  }
Link to comment
Share on other sites

You're missing quotes right and left, it looks like. Start with the line where you echo the timezone definition (any reason you're outputting that instead of actually defining the constant?) and go from there. If your code editor doesn't support syntax coloring, take a look at one that does - I think maybe Notepad++ does? The system I'm using at work doesn't have it installed and I can't remember off the top of my head.

Link to comment
Share on other sites

Only skimmed through the code but I found these issues.

 

On Line 11 you have an malformed echo statement. Which is not needed.

 

On line 16 you need to escape the double quotes within your double quoted string

 

On line 98 you have placed some random HTML. It needs to be echoed

Link to comment
Share on other sites

Only skimmed through the code but I found these issues.

 

On Line 11 you have an malformed echo statement. Which is not needed.

 

On line 16 you need to escape the double quotes within your double quoted string

 

On line 98 you have placed some random HTML. It needs to be echoed

Ok I made a few changes and got the following Parse error

 

 

Parse error: syntax error, unexpected $end in /home/u506124311/public_html/ag/page.php on line 569

Here  is my current code

<?php


define('TIMEZONE', 'Africa/Harare');
date_default_timezone_set(TIMEZONE);
?>
<html><br>
<b><u>Chat Beta:</u></b>

<br><span style="color:#751919"><b>Welcome to the Chat, </b></span>
<span style="color:#3f4f5f"><b>
<?php
echo
$_SERVER['HTTP_X_MXIT_NICK'];
?></span>
<br><span style="color:#828282"><b>
<?php echo date('D H:i:s'); ?></b></span>
<br><b>NO MODERATION SPOTS OPEN YET!</b>
<br><a href="page.php">Refresh</a>
</html>
<?
// database connection info
$conn = mysql_connect('*****','*******','*******') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('*********',$conn) or trigger_error("SQL", E_USER_ERROR);
///////////////////////////////////////////


$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con);
$result = mysql_query($query0);
                $myrows = mysql_fetch_array($result);
  if (mysql_num_rows($query0) != 0)
  {
////////////////////////////////////////////
// find out how many rows are in the table 
$sql = "SELECT COUNT(*) FROM StringyChat";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 20;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   // cast var as int
   $currentpage = (int) $_GET['currentpage'];
} else {
   // default page num
   $currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
   // set current page to last page
   $currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
   // set current page to first page
   $currentpage = 1;
} // end if

// the offset of the list, based on current page 
$offset = ($currentpage - 1) * $rowsperpage;




    /*
     * StringyChat
     *
	 * Please refer to readme.txt supplied with the StringyChat distribution for information on
	 * installing and configuring. 
	 *
     */





define('TIMEZONE', 'Africa/Harare');
date_default_timezone_set(TIMEZONE);



    include("chat_code_header.php");

    $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); 
    $myrow = mysql_fetch_array($result); 

    $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on
	$install_url = $myrow["install_url"]; // URL to install dir of StringyChat
    $name_size = $myrow["name_size"]; // Maximum size of the name
    $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit.
    $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split.
    $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display.
    $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes
	$email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to

    
	if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) 
    { 
    $StringyChat_name = $_POST['StringyChat_name'];
    $StringyChat_message = $_POST['StringyChat_message'];
    }
	
?>

echo '<div id="StringyChat">';

<?
    // Check if visitor's IP is banned.  If so, do not display the form,
    // show a banned IP message instead.

$name = $_SERVER["HTTP_X_MXIT_NICK"];
if(!isset($name))
{
	$name = "SYSOP";
}




    $ip = $_SERVER["HTTP_X_MXIT_USERID_R"];

if(!isset($ip))
{
	$ip = "Debater";
}


    $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\"";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    if($myrow["ip"] == "") {	// Checks if IP not found in banned list




?>
<html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>">
      <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20">
      <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea>
      <br>
      <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message">
    </form>
</html>

<?

    } else {
      echo "<span style='color:#10ce59'><u>Dear User, you have been banned from the Chat due to not following the rules. You will need to come back regularly to see if you were unbanned. Until then, goodbye!</u></span><br>";
    }
    
    // Should we try to create a post?
    if (isset($StringyChat_name) && isset($StringyChat_message)) {

        // Remove whitespaces and slashes.
        $name = trim(stripslashes($StringyChat_name));
        $message = trim(stripslashes($StringyChat_message));

        
            // Check name and message have been entered.
            if (strlen($name) > 0 && strlen($message) > 0) {
                
                // Limit the size of the fields as per variable defnitions.
                if (strlen($name) > $name_size) {
                    $name = substr($name, 0, $name_size);
                }
                if (strlen($message) > $message_size) {
                    $message = substr($message, 0, $message_size);
                }
                
                // Remove new lines from name.
                $name = str_replace("\n", " ", $name);
                
				// Stripping out \r's so email formattnig appears correctly.
				$message = str_replace("\r", "", $message);
				
				// Create an email-friendly version of the message.
				$message_emailable = str_replace("<br>", "\n", $message);
				$result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db);
                while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) {
	              $the_word = $myrow_wordswap["word"];
                  $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable);
                }

                // Replace the new lines with encoded line breaks for HTML (thanks milahu).
                $message = str_replace("\n", "c#lb", $message);

                // Use HTML encoding on ame and message so database doesn't misinterpret data.
	            $name = htmlentities($name);
                $message = htmlentities($message, ENT_COMPAT);
				
                
                
                // IP address of submitter and time of post.
$ip = $_SERVER["HTTP_X_MXIT_USERID_R"];

if(!isset($ip))
{
	$ip = "Debater";
}

$name = $_SERVER["HTTP_X_MXIT_NICK"];
$msg = $_POST['StringyChat_message'];
$post_time = date("U");
$mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"];
$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];



if(!isset($mxitid))
{
	$mxitid = "DEFAULT";

}
if(!isset($name))
{
	$name = "Debater";
}
if ($testip == "m70141099002") {
    $name = "Admin";
}




                // check to see if a duplicate exists
                $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 30 )";
                $result = mysql_query($sql);
                $myrow = mysql_fetch_array($result);

                if($myrow["StringyChat_message"] == "") {	// Checks if record not matching in db
                  // Save the record
                  $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time,mxit_id) VALUES (\"$ip\",\"$name\",\"$msg\",\"$post_time\",\"$mxitid\")";
                  $result = mysql_query($sql);
				  
				  

                } else {
                  echo "<span style='color:#10ce59'>Duplicate post detected!</span><p>";
                }                
            }
            else {
                echo "<span style='color:#10ce59'>You can't send blanks!</span><br><br>";
            }

      unset($_POST["StringyChat_name"]);
      unset($_POST["StringyChat_message"]);
      unset($StringyChat_ip);
      unset($StringyChat_name);
      unset($StringyChat_message);
      unset($StringyChat_time);
      unset($mxit_id);
	 unset($id);

    }
    
// get the info from the db 
$sql = "SELECT id, StringyChat_time, StringyChat_name, StringyChat_message, StringyChat_ip FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);



function filterBadWords($str)
{
	
	
    $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); 
    $replacements = "#~";
    
    while($row = mysql_fetch_assoc($result1))
    {
          $str = eregi_replace($row['word'], str_repeat('#~', strlen($row['word'])), $str);
    }  
    
    return $str;
}



// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($result)) 
//while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'])
 {
   // echo data
   //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'])
$admin = array('m70141099002' , 'Debater', '27765238453', '');
$moderator = array('m65795687002', 'm57010835002' , 'm50079252002');
$pc = array('');
$helper = array('' , '');
$globalhelper = array('');
$id = $list["id"];
$nname = $list["StringyChat_name"];

$ipi = $list["StringyChat_ip"];
$form = '<a href="http://imagecrab.freeserver.me/ag/ban.php?id=' . $id . '&ip=' . $ipi . '&nname=' . $nname .'"> [M] </a>';
$name = $_SERVER["HTTP_X_MXIT_NICK"];
$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];


if(!isset($name))
{
	$name = "Debater";
}


if(!isset($testip))
{
	$testip = "Debater";
}



if (in_array($testip, $admin))
{
if (in_array($list['StringyChat_ip'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  ' ' . '</span>'. '<span style="color:red">' . '<b>'   . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
elseif (in_array($list['StringyChat_ip'], $moderator))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:green">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
elseif (in_array($list['StringyChat_ip'], $pc))

{
   print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:purple">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
elseif (in_array($list['StringyChat_ip'], $helper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}

elseif (in_array($list['StringyChat_ip'], $globalhelper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:#0365B8">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords($list['StringyChat_message']) .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';
}
}

elseif (in_array($testip, $moderator ))
{
if (in_array($list['StringyChat_ip'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  ' ' . '</span>'. '<span style="color:red">' . '<b>'   . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $moderator))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:green">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $pc))

{
   print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:purple">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $helper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}

elseif (in_array($list['StringyChat_ip'], $globalhelper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:#0365B8">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />';
}
}






























else
{if (in_array($list['StringyChat_ip'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '</span>'. '<span style="color:red">' . '<b>'   . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $moderator))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:green">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $pc))

{
   print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:purple">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $helper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}

elseif (in_array($list['StringyChat_ip'], $globalhelper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:#0365B8">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />';
}

}



}






    // Load up the last few posts.  The number to load is defined by the "ShowPostNum" variable.
    $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db);

    include("sort_widths.php");

    while ($myrow = mysql_fetch_array($result)) {
      $msg = $myrow["StringyChat_message"];
	  
	  // Convert the encoded line break into an actual <br> tag (thanks milahu)
      $msg = str_replace("c#lb", "<br>", $msg);

      // Convert the encoded image tag into a html tag
      $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg);
	  
	  // split the lines
      $msg = htmlwrap($msg, $line_length);

      $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db);
      while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) {
	    $the_word = $myrow_wordswap["word"];
        $msg = ereg_replace($the_word, ":-x",$msg);
      }

   
    }
   ?>     
<?









// end while

/******  build the pagination links ******/
// range of num links to show
$range = 3;

// if not on page 1, don't show back links
if ($currentpage > 1) {
   // show << link to go back to page 1
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
   // get previous page num
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if 

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) {
         // 'highlight' it but don't make a link
         echo " [<b>$x</b>] ";
      // if not current page...
      } else {
         // make it a link
         echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
      } // end else
   } // end if 
} // end for

// if not on last page, show forward and last page links        
if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page 
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
   // echo forward link for lastpage
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/

?><br>
<html>    <span style="color:#828282"><i>Type Your Message NOW!</i></span>
	<p><a href="page.php">Refresh</a>
	<br><a href="http://imagecrab.webatu.com/try/index.php">Home</a> | <a 
	</html>

 }

  else
  {
    <html>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
Username:<br>
<input type="text" name="username" ><br>
<input type="hidden" value="<?php echo $_SERVER['HTTP_X_MXIT_LOGIN']; ?>" name"userid" >

<br><br>
<input type="submit" value="Submit">
</form>
</html>

<?
$usernames = $_GET['username'];
$mid = $_GET['userid'];

$sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")";
                  $result = mysql_query($sql0);


?>
  }
Link to comment
Share on other sites

 

Ok I made a few changes and got the following Parse error

Here  is my current code

<?php


define('TIMEZONE', 'Africa/Harare');
date_default_timezone_set(TIMEZONE);
?>
<html><br>
<b><u>Chat Beta:</u></b>

<br><span style="color:#751919"><b>Welcome to the Chat, </b></span>
<span style="color:#3f4f5f"><b>
<?php
echo
$_SERVER['HTTP_X_MXIT_NICK'];
?></span>
<br><span style="color:#828282"><b>
<?php echo date('D H:i:s'); ?></b></span>
<br><b>NO MODERATION SPOTS OPEN YET!</b>
<br><a href="page.php">Refresh</a>
</html>
<?
// database connection info
$conn = mysql_connect('*****','*******','*******') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('*********',$conn) or trigger_error("SQL", E_USER_ERROR);
///////////////////////////////////////////


$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con);
$result = mysql_query($query0);
                $myrows = mysql_fetch_array($result);
  if (mysql_num_rows($query0) != 0)
  {
////////////////////////////////////////////
// find out how many rows are in the table 
$sql = "SELECT COUNT(*) FROM StringyChat";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 20;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   // cast var as int
   $currentpage = (int) $_GET['currentpage'];
} else {
   // default page num
   $currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
   // set current page to last page
   $currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
   // set current page to first page
   $currentpage = 1;
} // end if

// the offset of the list, based on current page 
$offset = ($currentpage - 1) * $rowsperpage;




    /*
     * StringyChat
     *
	 * Please refer to readme.txt supplied with the StringyChat distribution for information on
	 * installing and configuring. 
	 *
     */





define('TIMEZONE', 'Africa/Harare');
date_default_timezone_set(TIMEZONE);



    include("chat_code_header.php");

    $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); 
    $myrow = mysql_fetch_array($result); 

    $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on
	$install_url = $myrow["install_url"]; // URL to install dir of StringyChat
    $name_size = $myrow["name_size"]; // Maximum size of the name
    $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit.
    $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split.
    $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display.
    $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes
	$email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to

    
	if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) 
    { 
    $StringyChat_name = $_POST['StringyChat_name'];
    $StringyChat_message = $_POST['StringyChat_message'];
    }
	
?>

echo '<div id="StringyChat">';

<?
    // Check if visitor's IP is banned.  If so, do not display the form,
    // show a banned IP message instead.

$name = $_SERVER["HTTP_X_MXIT_NICK"];
if(!isset($name))
{
	$name = "SYSOP";
}




    $ip = $_SERVER["HTTP_X_MXIT_USERID_R"];

if(!isset($ip))
{
	$ip = "Debater";
}


    $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\"";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    if($myrow["ip"] == "") {	// Checks if IP not found in banned list




?>
<html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>">
      <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20">
      <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea>
      <br>
      <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message">
    </form>
</html>

<?

    } else {
      echo "<span style='color:#10ce59'><u>Dear User, you have been banned from the Chat due to not following the rules. You will need to come back regularly to see if you were unbanned. Until then, goodbye!</u></span><br>";
    }
    
    // Should we try to create a post?
    if (isset($StringyChat_name) && isset($StringyChat_message)) {

        // Remove whitespaces and slashes.
        $name = trim(stripslashes($StringyChat_name));
        $message = trim(stripslashes($StringyChat_message));

        
            // Check name and message have been entered.
            if (strlen($name) > 0 && strlen($message) > 0) {
                
                // Limit the size of the fields as per variable defnitions.
                if (strlen($name) > $name_size) {
                    $name = substr($name, 0, $name_size);
                }
                if (strlen($message) > $message_size) {
                    $message = substr($message, 0, $message_size);
                }
                
                // Remove new lines from name.
                $name = str_replace("\n", " ", $name);
                
				// Stripping out \r's so email formattnig appears correctly.
				$message = str_replace("\r", "", $message);
				
				// Create an email-friendly version of the message.
				$message_emailable = str_replace("<br>", "\n", $message);
				$result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db);
                while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) {
	              $the_word = $myrow_wordswap["word"];
                  $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable);
                }

                // Replace the new lines with encoded line breaks for HTML (thanks milahu).
                $message = str_replace("\n", "c#lb", $message);

                // Use HTML encoding on ame and message so database doesn't misinterpret data.
	            $name = htmlentities($name);
                $message = htmlentities($message, ENT_COMPAT);
				
                
                
                // IP address of submitter and time of post.
$ip = $_SERVER["HTTP_X_MXIT_USERID_R"];

if(!isset($ip))
{
	$ip = "Debater";
}

$name = $_SERVER["HTTP_X_MXIT_NICK"];
$msg = $_POST['StringyChat_message'];
$post_time = date("U");
$mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"];
$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];



if(!isset($mxitid))
{
	$mxitid = "DEFAULT";

}
if(!isset($name))
{
	$name = "Debater";
}
if ($testip == "m70141099002") {
    $name = "Admin";
}




                // check to see if a duplicate exists
                $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 30 )";
                $result = mysql_query($sql);
                $myrow = mysql_fetch_array($result);

                if($myrow["StringyChat_message"] == "") {	// Checks if record not matching in db
                  // Save the record
                  $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time,mxit_id) VALUES (\"$ip\",\"$name\",\"$msg\",\"$post_time\",\"$mxitid\")";
                  $result = mysql_query($sql);
				  
				  

                } else {
                  echo "<span style='color:#10ce59'>Duplicate post detected!</span><p>";
                }                
            }
            else {
                echo "<span style='color:#10ce59'>You can't send blanks!</span><br><br>";
            }

      unset($_POST["StringyChat_name"]);
      unset($_POST["StringyChat_message"]);
      unset($StringyChat_ip);
      unset($StringyChat_name);
      unset($StringyChat_message);
      unset($StringyChat_time);
      unset($mxit_id);
	 unset($id);

    }
    
// get the info from the db 
$sql = "SELECT id, StringyChat_time, StringyChat_name, StringyChat_message, StringyChat_ip FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);



function filterBadWords($str)
{
	
	
    $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); 
    $replacements = "#~";
    
    while($row = mysql_fetch_assoc($result1))
    {
          $str = eregi_replace($row['word'], str_repeat('#~', strlen($row['word'])), $str);
    }  
    
    return $str;
}



// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($result)) 
//while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'])
 {
   // echo data
   //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message'])
$admin = array('m70141099002' , 'Debater', '27765238453', '');
$moderator = array('m65795687002', 'm57010835002' , 'm50079252002');
$pc = array('');
$helper = array('' , '');
$globalhelper = array('');
$id = $list["id"];
$nname = $list["StringyChat_name"];

$ipi = $list["StringyChat_ip"];
$form = '<a href="http://imagecrab.freeserver.me/ag/ban.php?id=' . $id . '&ip=' . $ipi . '&nname=' . $nname .'"> [M] </a>';
$name = $_SERVER["HTTP_X_MXIT_NICK"];
$testip = $_SERVER["HTTP_X_MXIT_USERID_R"];


if(!isset($name))
{
	$name = "Debater";
}


if(!isset($testip))
{
	$testip = "Debater";
}



if (in_array($testip, $admin))
{
if (in_array($list['StringyChat_ip'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  ' ' . '</span>'. '<span style="color:red">' . '<b>'   . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
elseif (in_array($list['StringyChat_ip'], $moderator))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:green">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
elseif (in_array($list['StringyChat_ip'], $pc))

{
   print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:purple">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
elseif (in_array($list['StringyChat_ip'], $helper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}

elseif (in_array($list['StringyChat_ip'], $globalhelper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';

}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:#0365B8">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords($list['StringyChat_message']) .  '<span style="color:#d8d8d8">'  . " - " . $ipi . '</span>' . '<br />';
}
}

elseif (in_array($testip, $moderator ))
{
if (in_array($list['StringyChat_ip'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  ' ' . '</span>'. '<span style="color:red">' . '<b>'   . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $moderator))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:green">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $pc))

{
   print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:purple">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $helper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}

elseif (in_array($list['StringyChat_ip'], $globalhelper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . $form .  '<span style="color:#0365B8">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />';
}
}






























else
{if (in_array($list['StringyChat_ip'], $admin))
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '</span>'. '<span style="color:red">' . '<b>'   . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $moderator))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:green">' .  '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $pc))

{
   print '<span style="color:gold">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:purple">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
elseif (in_array($list['StringyChat_ip'], $helper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}

elseif (in_array($list['StringyChat_ip'], $globalhelper))

{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:blue">' .  '<b>' . $list['StringyChat_name'] . '</span>' . '<span style="color:green">' . ' ' . '[G.H]' . '</span>' . '</b>' . ' : ' . '<span style="color:blue">' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />';
}
else
{
   print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] )  . ') ' . '</span>' . '<span style="color:#0365B8">' .  '<b>' . $list['StringyChat_name'] . '</b>' . '</span>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />';
}

}



}






    // Load up the last few posts.  The number to load is defined by the "ShowPostNum" variable.
    $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db);

    include("sort_widths.php");

    while ($myrow = mysql_fetch_array($result)) {
      $msg = $myrow["StringyChat_message"];
	  
	  // Convert the encoded line break into an actual <br> tag (thanks milahu)
      $msg = str_replace("c#lb", "<br>", $msg);

      // Convert the encoded image tag into a html tag
      $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg);
	  
	  // split the lines
      $msg = htmlwrap($msg, $line_length);

      $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db);
      while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) {
	    $the_word = $myrow_wordswap["word"];
        $msg = ereg_replace($the_word, ":-x",$msg);
      }

   
    }
   ?>     
<?









// end while

/******  build the pagination links ******/
// range of num links to show
$range = 3;

// if not on page 1, don't show back links
if ($currentpage > 1) {
   // show << link to go back to page 1
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
   // get previous page num
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if 

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) {
         // 'highlight' it but don't make a link
         echo " [<b>$x</b>] ";
      // if not current page...
      } else {
         // make it a link
         echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
      } // end else
   } // end if 
} // end for

// if not on last page, show forward and last page links        
if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page 
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
   // echo forward link for lastpage
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/

?><br>
<html>    <span style="color:#828282"><i>Type Your Message NOW!</i></span>
	<p><a href="page.php">Refresh</a>
	<br><a href="http://imagecrab.webatu.com/try/index.php">Home</a> | <a 
	</html>

 }

  else
  {
    <html>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
Username:<br>
<input type="text" name="username" ><br>
<input type="hidden" value="<?php echo $_SERVER['HTTP_X_MXIT_LOGIN']; ?>" name"userid" >

<br><br>
<input type="submit" value="Submit">
</form>
</html>

<?
$usernames = $_GET['username'];
$mid = $_GET['userid'];

$sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")";
                  $result = mysql_query($sql0);


?>
  }

Ok I changed the following part

<?
$usernames = $_GET['username'];
$mid = $_GET['userid'];

$sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")";
                  $result = mysql_query($sql0);


?>
  }

to 

if ($_POST["submit"]) {

$usernames = $_GET['username'];
$mid = $_GET['userid'];

$sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")";
                  $result = mysql_query($sql0);

}

but still the same error

Link to comment
Share on other sites

Unexpected $end usually means you have a "{" somewhere without a corresponding "}".

 

You also have some php code amongst your HTML without surrounding <?php..?> tags

Thanks

 

now im getting the following error

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/u506124311/public_html/ag/page.php on line 29

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/u506124311/public_html/ag/page.php on line 31

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/u506124311/public_html/ag/page.php on line 32

What I'm trying to do is to look up the value in the table named Users in the field mxitid if the user mxit id is the one hes using I want the username he chosen for that specific mxitid to display as the name in line 207

Edited by cobusbo
Link to comment
Share on other sites

Read what the error message is telling you then look at the code on that line.

 

It says the MySQL link resource is invalid here:

 

$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con);

 

So why is it invalid? Look here:

 

$conn = mysql_connect('*****','*******','*******') or trigger_error("SQL", E_USER_ERROR);

 

Not difficult.

Link to comment
Share on other sites

Read what the error message is telling you then look at the code on that line.

 

It says the MySQL link resource is invalid here:

 

$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con);

 

So why is it invalid? Look here:

 

$conn = mysql_connect('*****','*******','*******') or trigger_error("SQL", E_USER_ERROR);

 

Not difficult.

Thank you

 

Stil got the following error

 

 

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/u506124311/public_html/ag/page.php on line 31

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/u506124311/public_html/ag/page.php on line33

 

here is the part with the error

$usernames = $_GET['username'];
$mid = $_GET['userid'];

$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $conn);
$result99 = mysql_query($query0);
                  if (mysql_num_rows($query0) != 0);
  {
$list99 = mysql_fetch_assoc($result99);

Link to comment
Share on other sites

It's still telling you that the MySQL handle is invalid. You need to check the results of each of the connect, db select, query calls BEFORE trying to use them to count the rows returned, to retrieve the data returned, etc.

 

Check your syntax against what the manual tells you to use. The manual is your friend. Use it.

Link to comment
Share on other sites

It's still telling you that the MySQL handle is invalid. You need to check the results of each of the connect, db select, query calls BEFORE trying to use them to count the rows returned, to retrieve the data returned, etc.

 

Check your syntax against what the manual tells you to use. The manual is your friend. Use it.

Well am I on the right way because what I'm trying to do is to 

 

 

check in the table named Users for for the field named mxitid if its = to $mxitid field and if its true to recall the value in the in the Username field of the table?

 

so basicly I want to 

//Check datababase
if mxitid in db - $mxitid

if (its true) {

show chat page

with line 207 $name = the username field from the db
}
else
{ show login form and script}


can someone help me with an example please.

Link to comment
Share on other sites

You're running the query twice.

 

YOU need to go and learn how this works from either the manual (php.net) or  do a tutorial.

 

Most of the issues you raise are debugging issues - not coding issues. Most of your errors are simple, obvious errors, which if you understood what you are doing, would be obvious to you also. SO, go take that tutorial or read the manual, there are plenty of examples of this on the net.

 

Your issue is with the following line s you don't need to run the mysql_query twice. If you understood what you were doing you would know this and would be sorting these obvious issues out yourself.

 

$query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $conn);

$result99 = mysql_query($query0);

 

Good luck.

Edited by wezhind
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.