000
23.10.2003, 00:21 Uhr
~Tomycat
Gast
|
hi, mein chat geht nicht www.lavacat.de/c/cz_chat.php
Code: |
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/apache/www/web78/html/c/cz_chat.php on line 177
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/apache/www/web78/html/c/cz_chat.php on line 183
|
PHP 4: |
-----------------cz_chat.php---------------------
<? // Datenbank schreibe $dhost = "localhost"; // hostname $dbuser = "web78"; // user $dpw = "*****"; // paßwort $dbname = "web78"; // Datenbankname
$db = @mysql_connect("$dhost","$dbuser","$dpw");
mysql_select_db($dbname);
$linec = 3;
if (empty($action)) ShowLoginForm(); elseif ($action == "posts") ShowAddPosts(); elseif ($action == "form") GetInput(); elseif ($action == "enter") Login();
function ShowLoginForm() { ?> <body bgcolor="||LC01|| <b>Wähle deinen nickname</b> <form name="chat" method="post" action="cz_chat.php" target="_top"> <input type="text" name="nick" size="20"> <input type="hidden" name="action" value="enter"> <input type="hidden" name="chat" value="<font color=FF0000><b>betritt den Raum um <? echo date("H:i"); ?></b></font>"> <input type="submit" name="Submit" value="und los!"> </form>
<? }
function Login() {
global $HTTP_SESSION_VARS; global $chat; global $nick;
session_start(); session_register("nick", $nick);
?>
<frameset rows="*,120" cols="*"> <frame name="posts" src="cz_chat.php?action=posts&nick=<? echo $nick; ?>&chat=<?php echo $chat; ?>"> <frame name="form" src="cz_chat.php?action=form&nick=<? echo $nick; ?>"> </frameset> <noframes> <body>
<p>Diese Seite benötigt Frames die Ihr Brwoser leider nicht unterstützt.</p>
</body> </noframes> </frameset>
<? }
function GetInput() {
global $HTTP_SESSION_VARS; global $chat; global $nick;
?>
<body bgcolor="||LC01||<table border=0 width=100%><tr><td> <form onSubmit="return doSubmit" name="chatform" method="post" action="cz_chat.php" target="posts"> <input type="text" name="chat" size="40"> <input type="hidden" name="nick" value="<? echo $nick; ?>"> <input type="button" onClick="doSubmit()" name="Submit" value="Chat!"> <input type="image" src="lachen.gif" name="DoFace1" value=" :) " onClick="sendFace(1)"> <input type="image" src="sauer.gif" name="DoFace2" value=" :( " onClick="sendFace(2)"> <input type="image" src="grinz.gif" name="DoFace3" value=" :D " onClick="sendFace(3)"> <input type="image" src="cool.gif" name="DoFace4" value=" :-) " onClick="sendFace(4)">
<select name="col"> <option name=Black>schwarz</option> <option name=Red>rot</option> <option name=Green>grün</option> <option name=Blue>blau</option> <option name=Orange>orange</option> </select>
</td> <td valign=top align=right><a href="http://www.codezilla.at/"><img src="logo.gif" width="216" height="70" border="0" alt="codezilla.at"></a></td></tr></table>
<input type="hidden" name="action" value="posts"> </form>
<script language="JavaScript">
function sendFace(faceNum) { switch(faceNum) { case 1: document.chatform.chat.value = ':)'; break; case 2: document.chatform.chat.value = ':('; break; case 3: document.chatform.chat.value = ':D'; break;
case 4: document.chatform.chat.value = ':-)'; break; } document.chatform.submit(); document.chatform.chat.value = ''; }
function doSubmit() { if(document.chatform.chat.value == '') { alert('Bitte Text eingeben!'); document.chatform.chat.focus(); return false; }
document.chatform.chat.value = '<font color="'+document.chatform.col[document.chatform.col.selectedIndex].name+'">'+document.chatform.chat.value+'</font>'; document.chatform.submit(); document.chatform.chat.value = ''; document.chatform.chat.focus(); return true; }
</script>
<? }
function ShowAddPosts() {
global $HTTP_SESSION_VARS; global $chat; global $nick;
echo '<meta http-equiv="refresh" content="10;URL=cz_chat.php?action=posts&nick=<? echo $nick; ?>">';
if(!empty($chat)) {
$strQuery = "insert into cz_chat values(0, '$chat', '$nick')"; mysql_query($strQuery);
}
$strQuery = "select texta, nick from cz_chat order by id desc limit 20"; $chats = mysql_query($strQuery);
while($chatline = mysql_fetch_array($chats)) { echo "<b>" . $chatline["nick"] . ":</b> " . swapFaces($chatline["texta"]) . "<br>"; } $query = "select * from cz_chat";
$result = mysql_query($query); $num = mysql_num_rows($result);
if ($num >= 10){ $querykilla = "delete from cz_chat"; $resultkilla = mysql_query($querykilla); }
}
function swapFaces($chatLine) {
$chatLine = str_replace(":)", "<img src='lachen.gif'>", $chatLine); $chatLine = str_replace(":(", "<img src='sauer.gif'>", $chatLine); $chatLine = str_replace(":D", "<img src='grinz.gif'>", $chatLine); $chatLine = str_replace(":-)", "<img src='cool.gif'>", $chatLine);
return $chatLine; }
?>
<!-- // -------------------------------------------------------------------------- // Dokumentationshinweise: // Programmname : codezilla.at chat v1.0 // Programmtyp : JavaScript + PHP 4 // Autor : Essl.Bernhard // Kontakt : admin@codezilla.at // Erstellt am : 2002 11 06 // Zweck : Chat
// Dieses Skript darf weitergegeben werden solange die Dokumentationshinweise // erhalten bleiben!
// In diesen Fall wäre es auch nett das Logo stehen zulassen, // ist aber nicht zwingend :)
// Besuchen Sie "http://www.codezilla.at" target="_blank">www.codezilla.at um weitere freie Skripte zu finden! // -------------------------------------------------------------------------- -->
|
--edit: Pablo. [ code ] und [ php ] tags gesetzt. Bei so langem Code bitte selber Board Tag benutzen :!: :smash: -- Dieser Post wurde am 23.10.2003 um 00:25 Uhr von Pablo Yanez Trujillo editiert. |