ricerocket Posted March 25, 2008 Share Posted March 25, 2008 Hi, I have a chat script and when I post "0" by iteself it doesn't show/post the message. Is this like making the script think that it's "NULL" or something? How do I get arround this? Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/ Share on other sites More sharing options...
roopurt18 Posted March 25, 2008 Share Posted March 25, 2008 You must be performing a check to determine if the message is worth posting. What check are you using? Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-500818 Share on other sites More sharing options...
ricerocket Posted March 25, 2008 Author Share Posted March 25, 2008 Heres the script: <?php ob_start(); $page_title='Chat Room'; include("scraps/mainTop.php"); if ($playerinfo[chatban] > 0){ if ($channel=="") $channel="chat_lines"; if ( $playerinfo[status] != "Member" ){ echo "<center>"; echo "~<a class=mainAJAX href=chat/ban.php>Ban a Player</a> | <a class=mainAJAX href=chat/view_all.php?channel=$channel>View all Messages</a> | <a class=mainAJAX href=chat.php?step=clear&channel=$channel>Clear Chat</a>~<p>"; echo "</center>"; } echo "You are banned from chat for $playerinfo[chatban] days for $playerinfo[cbanreason]."; } else { if ($playerinfo) { if ( $playerinfo[status] != "Member" ) { if ($id) { if ( $step == 'delete' ){ $message2 = mysql_fetch_array(mysql_query( "select * from $channel where id='$id'")); $message = mysql_real_escape_string($message2[message]); $delete_query = "update $channel set deleted = 'Y', message = '<span style=\"text-decoration: line-through\">$message</span>', timesent='$message2[timesent]' where id='$id'"; if (mysql_query($delete_query)); else echo mysql_error()."on $delete_query"; } } if ( $step == 'clear'){ echo "<br><center>Due to log keeping reasons, please do not use this function</center>"; include("scraps/mainBottom.php"); exit; } if ( $step == 'rachelbutton' ){ $clear = mysql_query( "delete from $channel" ); $then = mysql_query( "insert into $channel (id,username,message) values ('','<b>Chat Message</b>','<font color=$playerinfo[chatdefcol]>$playerinfo[username] cleared chat</font>')" ); $then = mysql_query( "insert into $channel (id,username,message) values ('','<b>Chat Message</b>','Genleo welcomes all to Chat')" ); } } if ($text && strlen(trim($text)) > 0 && !($playerinfo[chatban] > 0) ) { $staff=0; $private=0; $dscript_act = "encode"; include ( "filter.php" ); $pusername=$playerinfo[username]; if ( $playerinfo[status] == "Manager" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=yellow>$pusername</font></a></font>"; } elseif ( $playerinfo[status] == "VManager" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><i><font color=#FF8000>$pusername</font></i></a></font>"; } elseif ( $playerinfo[status] == "Coder" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=red>$pusername</font></a></font>"; } elseif ( $playerinfo[status] == "admin" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#2FE800>$pusername</font></a></font>"; } elseif ( $playerinfo[status] == "Editor" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#32D3CB>$pusername</font></a></font>"; } elseif ( $playerinfo[status] == "Chat Monitor" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=brown>$pusername</font></a>"; } elseif ( $playerinfo[status] == "Trainee" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#C47D7D>$pusername</font></a>"; } elseif ( $playerinfo[job] == "Gpaper"){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$pusername</font></a>"; }elseif ( $playerinfo[job] == "E-Paper Editor" ) { $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$pusername</font></a>"; } elseif ( $playerinfo[donated] > "0" ){ if( $playerinfo[justdonated] > "0") { $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#A020F0>$pusername</font></a>"; } else { $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#dfdfdf >$pusername</font></a>"; } } else{ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#dfdfdf >$pusername</font></a>"; } $username = addslashes($username); if ( $playerinfo[status] != "Member" ){ if ( substr( $text, 0, 4 ) == "[msg" ){ $text = substr( $text, 5 ); $username = '<font color=white><b>Staff Announcement:</b></font>'; } if(substr($text,0,5) == "[warn"){ $text = substr($text,6); $username = '<font color=red><b>Staff Warning:</b></font>'; } if ( substr( $text, 0, 6 ) == "[staff" ){ if ( $playerinfo[status] == "Manager" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent ><font color=yellow>$pusername</font></a></font>"; $cheese = 'yellow'; } elseif ( $playerinfo[status] == "VManager" && $playerinfo[job] != "Coder"){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#FF8000>$pusername</font></a></font>"; $cheese = '#FF8000'; } elseif ( $playerinfo[status] == "VManager" && $playerinfo[job] == "Coder"){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=red>$pusername</font></a></font>"; $cheese = 'red'; } elseif ( $playerinfo[status] == "Coder" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=red>$pusername</font></a></font>"; $cheese = 'red'; } elseif ( $playerinfo[status] == "admin" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#2FE800>$pusername</font></a></font>"; $cheese = '#2FE800'; } elseif ( $playerinfo[status] == "Editor" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#32D3CB>$pusername</font></a></font>"; $cheese = '#32D3CB'; } elseif ( $playerinfo[status] == "Chat Monitor" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#993333>$pusername</font></a>"; $cheese = '#993333'; } elseif ( $playerinfo[status] == "Trainee" ){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#C47D7D>$pusername</font></a>"; $cheese = '#C47D7D'; } elseif ( $playerinfo[job] == "E-Paper Editor"){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$pusername</font></a>"; $cheese = '#1874CD'; } elseif ( $playerinfo[job] == "Gpaper"){ $username = "<a class=mainAJAX href=view.php?id=$playerinfo[id] target=_parent><font color=#1874CD>$pusername</font></a>"; $cheese = '#1874CD'; } //change default font color $playerinfo[chatdefcol] = "#dfdfdf"; $text = "</font><font color=$cheese>Staff message from $username</font>> <font color=".$playerinfo[chatdefcol]."></b>" . substr( $text, 7 ) . "</b></font></font>"; $username = ''; $staff = "1"; } if ( substr( $text, 0, 3 ) == "[me" ){ $text = "<i>~ $pusername" . substr( $text, 3 ) . "</i>"; $username = ''; } if ( substr( $text, 0, 5 ) == "[priv" && $playerinfo[id] == 4){ $userx = strpos( $text, " " ); $puser = substr( $text, 1, $userx ); if ( str_replace( " ", "", $puser ) != "" ){ $text = "Private message from $playerinfo[username]> <font color=white>" . substr( $text, $userx + 1 ) . "</font>"; $private = $puser; $username = ''; } } }else{ if ( substr( $text, 0, 3 ) == "[me" ){ $text = "<i>~ $playerinfo[username]" . substr( $text, 3 ). "</i>"; $username = ''; } } $earlier=mysql_fetch_array(mysql_query("select * from $channel order by id desc limit 1")); // $text = mysql_real_escape_string(trim($text)); if ($earlier[username]!=$username||$earlier[message]!="<font color=$playerinfo[chatdefcol]>$text</font>") { $then = mysql_query( "insert into $channel (id, userid, username, message, staff, private, timesent) values ('', '$playerinfo[id]', '$username', '<font color=$playerinfo[chatdefcol]>$text</font>', '$staff', '$private', '$timestampy')" ) or die(mysql_error()); $setlines = mysql_query( "update userdb set chatlines=chatlines+1 where id='$playerinfo[id]'" ); } } echo "<br><center> <a class=mainAJAX href=chat.php>Main Chat</a> | <a class=mainAJAX href=chat.php?channel=nchatlines>Noob Chat</a> </center></br>"; if ($channel=="") $channel="chat_lines"; if ( $playerinfo[status] != "Member" ){ echo "<center>"; echo "~<a class=mainAJAX href=chat/ban.php>Ban a Player</a> | <a class=mainAJAX href=chat/view_all.php?channel=$channel>View all Messages</a> | <a class=mainAJAX href=chat.php?step=clear&channel=$channel>Clear Chat</a>~<p>"; echo "</center>"; } $setact = mysql_query( "update userdb set ccheck='$realtime' where id='$playerinfo[id]'" ); $playerinfo['ccheck']=$realtime; $_SESSION['playerinfo']=$playerinfo; echo "<DIV ID=\"chatTextContainer\">" ; if ( $playerinfo[status] != Member ){ $chatpull = mysql_query( "SELECT * FROM $channel where deleted!='Y' ORDER BY id DESC, id DESC LIMIT 0,20" ); while ( $display = mysql_fetch_array( $chatpull ) ){ $muted = mysql_fetch_array(mysql_query("select * from chat_mutes where userid='$playerinfo[id]' && muteid='$display[userid]'")); $display[message] = str_replace( "`Stuff`", "$playerinfo[username]", $display[message] ); if ( $playerinfo[status] != "Member" ){ if ( $display['private'] > 0 && $display['private'] == $playerinfo[id] ){ echo "[<a class=mainAJAX href=chat.php?step=delete&channel=$channel&id=$display[id]>D</a>]"; } elseif ( $display['private'] == 0 ){ echo "[<a class=mainAJAX href=chat.php?step=delete&channel=$channel&id=$display[id]>D</a>]"; }else{ echo ""; } } $stampcheck = mysql_query("select * from userdb where id='$playerinfo[id]'"); $stampycheck = mysql_fetch_array($stampcheck); if ($stampycheck[chatstamp] == "Y"){ if ($stampycheck[stampfont]){echo"<font color=$stampycheck[stampfont]>";} echo "$display[timesent] "; if ($stampycheck[stampfont]){echo"</font>";} } if ($muted) { echo " $display[username]> Message Muted.<br>"; } elseif ( !$display[username] ){ if ( $display[staff] == "1" && $playerinfo[status] == "Member" ){ echo ""; }else{ if ( $display['private'] > 0 ){ if ( $display['private'] == "$playerinfo[id]" ){ echo " $display[message]<br>"; }else{ echo ""; } }else{ echo " $display[message]<br>"; } } }else{ echo " $display[username]> $display[message]<br>"; } } echo "<p>"; }else{ $chatpull = mysql_query( "SELECT * FROM $channel where staff='0' and deleted!='Y' ORDER BY id DESC LIMIT 0,20" ); while ( $display = mysql_fetch_array( $chatpull ) ){ $muted = mysql_fetch_array(mysql_query("select * from chat_mutes where userid='$playerinfo[id]' && muteid='$display[userid]'")); $display[message] = str_replace( "`Stuff`", "$playerinfo[username]", $display[message] ); $stampcheck = mysql_query("select * from userdb where id='$playerinfo[id]'"); $stampycheck = mysql_fetch_array($stampcheck); if ($stampycheck[chatstamp] == "Y"){ if ($stampycheck[stampfont]){echo"<font color=$stampycheck[stampfont]>";} echo " $display[timesent] "; if ($stampycheck[stampfont]){echo"</font>";} } if ($muted) { echo " $display[username]> Message Muted.<br>"; }else if ( !$display[username] ){ if ( $display[staff] == "1" && $playerinfo[status] == "Member" ){ echo ""; }else{ if ( $display['private'] > 0 ){ if ( $display['private'] == "$playerinfo[id]" ){ echo " $display[message]<br>"; }else{ echo ""; } }else{ echo " $display[message]<br>"; } } }else{ echo " $display[username]> $display[message]<br>"; } } echo "<p>"; } echo"<br>"; echo "</DIV>"; echo ' <table cellspacing=5><tr><td> <form class="mainAJAX" action="chat.php" method=post name=chatform> <input type=hidden name=channel value='.$channel.'> <input type=text name=text id="entry" size=50 maxlength=120> <input type=submit value=Say> </form> </td><td> <ul class="nav"> <li onmouseover="createColorBox();document.getElementById(\'test\').style.display=\'block\'" onmouseout="document.getElementById(\'test\').style.display=\'none\'"> <input type=button value="Color"> <ul id=test> <li id=test2></li> </ul> </li> </ul> </td></tr></table> <font color=white></i></b></u> <br><br> If you no longer wish to receive chat messages from a particular player, click <a class=mainAJAX href=account.php?action=chatopt&type=mute>here</a>. <br>'; } else { echo "<br>Your session has expired, Please Click <a href=http://www.site.com>Here</a><br/>"; } } ?> <script> document.chatform.text.focus(); document.getElementById('entry').focus(); </script> <? include("scraps/mainBottom.php"); ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-500822 Share on other sites More sharing options...
roopurt18 Posted March 26, 2008 Share Posted March 26, 2008 I don't have the patience to sort through all that code. Somewhere in there you have a check that basically says: "If the incoming message is not empty, then do this" Can you find and paste that code? Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-500962 Share on other sites More sharing options...
thedarkwinter Posted March 26, 2008 Share Posted March 26, 2008 I don't have the patience either, but near the top i see the line if ($playerinfo[chatban] > 0){ That got anything to do with it? Otherwise, look for other >0's Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-501361 Share on other sites More sharing options...
roopurt18 Posted March 26, 2008 Share Posted March 26, 2008 It's probably something like: if( !empty($msg) ){ } Some of the PHP functions will consider certain values empty even when we don't want them to, such as '0'. I'm going from memory here so I could be mistaken. Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-501393 Share on other sites More sharing options...
ricerocket Posted March 27, 2008 Author Share Posted March 27, 2008 Can you explain to me what this means? <script> document.chatform.text.focus(); document.getElementById('entry').focus(); </script> Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-501824 Share on other sites More sharing options...
roopurt18 Posted March 27, 2008 Share Posted March 27, 2008 It's Javascript. It places the cursor in a field on the page. Link to comment https://forums.phpfreaks.com/topic/97879-number-0-not-posting-in-chat/#findComment-501927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.