MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 30th, 2002, 09:56 AM
rharmsen rharmsen is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 2 rharmsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
a mysql driven chat script

what is wrong wit this file it won't work

<?
create database chat

create table chatScript
(
pk_Id int unsigned auto_increment,
theText varchar(100) not null,
theNick varchar(20) not null,
primary key(pk_Id),
unique id(pk_Id)
);
connect chat;
insert into chatScript values(0, 'This is a test message', 'TestUser');

function ShowLoginForm() {
?>
<b>Enter Your NickName</b>
<form name="chat" method="post" action="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>Enters the Room</b></font>">
<input type="submit" name="Submit" value="Submit">
</form>
}
<?php

function Login() {

global $chat;
global $nick;

session_start();
session_register("nick", $nick);
?>

<frameset rows="563,62" cols="*">
<frame name="posts" src="chat.php?action=posts&nick=<?php echo $nick; ?>&chat=<?php echo $chat; ?>">
<frame name="form" src="chat.php?action=form&nick=<?php echo $nick; ?>">
</frameset>

<noframes>
<body>

<p>This page uses frames, but your browser doesn't support them.</p>

</body>
</noframes>
</frameset>

<?php
}

function doSubmit()
{

if(document.chatform.chat.value == '') {
alert('Please enter some text!');
document.chatform.chat.focus();
return false;

}

document.chatform.submit();
document.chatform.chat.focus();

return true;

}
function GetInput() {

global $HTTP_SESSION_VARS;
global $chat;
global $nick;

?>

<form onSubmit="return doSubmit" name="chatform" method="post" action="chat.php" target="posts">
<input type="text" name="chat">
<input type="hidden" name="nick" value="<?php echo $nick; ?>">
<input type="button" onClick="doSubmit()" name="Submit" value="Say">
<select name="col">
<option>Black</option>
<option>Red</option>
<option>Green</option>
<option>Blue</option>
<option>Orange</option>
</select>

<input type="button" name="DoFace1" value=" " onClick="sendFace(1)">
<input type="button" name="DoFace2" value=" " onClick="sendFace(2)">
<input type="button" name="DoFace3" value=" " onClick="sendFace(3)">
<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 = '';
break;
}

document.chatform.submit();
document.chatform.chat.value = '';
}

function doSubmit()
{

if(document.chatform.chat.value == '') {
alert('Please enter some text!');
document.chatform.chat.focus();
return false;

}

document.chatform.chat.value = '<font color="'+document.chatform.col[document.chatform.col.selectedIndex].text+'">'+document.chatform.chat.value+'</font>';

document.chatform.submit();
document.chatform.chat.value = '';
document.chatform.chat.focus();

return true;

}

</script>

<?php
}
global $HTTP_SESSION_VARS;
global $chat;
global $nick;
print '<meta http-equiv="refresh" content="10;URL=chat.php?action=posts&nick=<?php echo $nick; ?>">';
$svrConn = mysql_connect("localhost", "admin", "password") or die("<b>Error:</b> Couldnt connect to database");

$dbConn = mysql_select_db("chat", $svrConn) or die ("<b>Error:</b> Couldnt connect to database");
if(!empty($chat)) {
$strQuery = "insert into chatScript values(0, '$chat', '$nick')";
mysql_query($strQuery);
}
$strQuery = "select theText, theNick from chatScript order by pk_Id desc limit 20";
$chats = mysql_query($strQuery);
while($chatline = mysql_fetch_array($chats)) {
print "<b>" . $chatline["theNick"] . ":</b> " . swapFaces($chatline["theText"]) . "<br>";
}
function swapFaces($chatLine) {

$chatLine = str_replace("", "<img src='smile.gif'>", $chatLine);
$chatLine = str_replace("", "<img src='frown.gif'>", $chatLine);
$chatLine = str_replace("", "<img src='bigsmile.gif'>", $chatLine);

return $chatLine;
}
if (empty($action))
ShowLoginForm();
elseif ($action == "posts")
ShowAddPosts();
elseif ($action == "form")
GetInput();
elseif ($action == "enter")
Login();
?>

please answer somebody

Reply With Quote
  #2  
Old June 30th, 2002, 11:31 AM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
What error message, if any, are you receiving? Any description you can provide would benefit us in determining the problem.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old June 30th, 2002, 08:42 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
As Frankie said, if you could please tell us the details of the error that you are receiving then we will be more than happy to help you diagnose the problem...

Reply With Quote
  #4  
Old July 1st, 2002, 06:10 AM
rharmsen rharmsen is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 2 rharmsen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
okay here is the detail

(i am dutch so i am not good in english)
the chat script file is locatet at http://members.lycos.nl/rharmsenchat/chat.php
The error is: Error: Couldnt connect to database
greetings Ruudz

Last edited by rharmsen : July 1st, 2002 at 06:14 AM.

Reply With Quote
  #5  
Old July 1st, 2002, 07:45 AM
Lindset Lindset is offline
weirdomoderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Alta, Norway
Posts: 370 Lindset User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Lindset Send a message via AIM to Lindset
Hi rharmsen

Quote:
$svrConn = mysql_connect("localhost", "admin", "password") or die("<b>Error:</b> Couldnt connect to database");

$dbConn = mysql_select_db("chat", $svrConn) or die ("<b>Error:</b> Couldnt connect to database");


It seems the error occured in one of those lines. It's not a syntax error.. Code-wise everything looks fine.. Are you sure the password, username, database-name and host is typed in correctly?
__________________
Best Regards,
Håvard Lindset

Reply With Quote
  #6  
Old December 6th, 2003, 12:19 PM
deepdown deepdown is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 4 deepdown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have used the correct login name, and password. (checked it by login in through terminal)

But is there any other options.. php.ini or anything I also need to edit ?

Failure;
[client 192.168.1.100] PHP Fatal error: Call to undefined function: mysql_connect() in /home/httpd/html/chat.php on line 144, referer: URL

Reply With Quote
  #7  
Old December 6th, 2003, 12:59 PM
deepdown deepdown is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 4 deepdown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Enable in /etc/httpd/php.ini

extension=mysql.so

.... then I got another failure instead;
[client 192.168.1.100] PHP Fatal error: Call to undefined function: showloginform() in /home/httpd/html/chat.php on line 169

Reply With Quote
  #8  
Old December 7th, 2003, 06:09 PM
deepdown deepdown is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 4 deepdown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Now I finally seem to get the script correct..
But there is something wrong..

I get this in ms explorer:
Quote:
TestUser: This is a test message
Enter Your NickName
________________
|_______________| Submit




Then when I enter a name in the textbox, I get;

URL

...in the "address textbox of explorer". And I don't get any further



The error message /var/log/httpd/accecc_log;

192.168.1.100 - - [08/Dec/2003:01:06:38 +0100] "GET /chat.php?action=posts&nick=<?php%20echo%20$nick HTTP/1.1" 200 478

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > a mysql driven chat script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway