|
|
Viewing Topic: Need some help
building a chat
in PHP |
earth4x |
Subject: "Need some help
building a chat
in P..."
Posted: @ 3:05 am on Feb 22 2007 |
|
|
Member #: 283 Rank: user - (5) Since: 02/22/07 Posts: 5
|
I'm trying to
build a small
chat in PHP,
but i'm having
some slight
problems and
need some
help.
first off, I
want to use
emoticons, and
I want to use
the str replace
code to make it
work, but it
doesn't...
$smile =
str_replace(&qu
ot; "
, '<img
src="c001.
gif">',
"$msg"
;
$msg being the
$_POST of a
text field (I
use a txt file
with fwrite to
build the
chat)
can anyone tell
me what i'm
doing wrong
?
also, I want to
be able to see
how many users
are connected
to the page,
without using
MySQL. Can
anyone guide me
on how I can do
this? I already
have each user
login and it
creates a
$_SESSION['user
name'] so i'm
guessing I can
make it work..
but I don't
know how
thanks!
|
Viewed: 17,518 Times | |  |
ki |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 10:05 am on Feb 22 2007
|
|
|
 Member #: 204 Rank: user - (50) Since: 09/16/06 Posts: 53 From: Florida
|
We'll need
more than that
to see the
problem. What
are you saving
it as to the
text file, try
using $msg =
str_replace...
for the smile
code
|
Viewed: 17,506 Times | |  |
earth4x |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 5:12 pm on Feb 22 2007
|
|
|
Member #: 283 Rank: user - (5) Since: 02/22/07 Posts: 5
|
ki
said...
<
i>
We'll need
more than that
to see the
problem. What
are you saving
it as to the
text file, try
using $msg =
str_replace...
for the smile
code
Code:
<?
session_start()
;
$user =
$_SESSION['use
rname'];
$msg =
"";
if
(isset($_POST[
'sendMsg'])){
$msg=$_POST['
message'];
$nomFic="
;messages.txt&
quot;;
$fic =
fopen($nomFic,
"a" ;
$txt =
fwrite($fic,&q
uot;<b>$u
ser dit
:</b>
$msg<br>
" ;
fclose($fic);
}
$smile =
array(":P
","
"
;
$text =
str_replace($sm
ile, '<img
src="c001
.gif">
',
"$msg&qu
ot ;
?>
Edited at 05:51:30 pm on 02/22/07
|
Viewed: 17,497 Times | |  |
bs0d |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 5:51 pm on Feb 22 2007
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
Why not use
mySQL? That is
going to be
your best
method.
I may have some
coding to fix
on disabling
smilies on the
edit page.
Testing now :)
:D 8-)
|
Viewed: 17,488 Times | |  |
earth4x |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 8:03 pm on Feb 22 2007
|
|
|
Member #: 283 Rank: user - (5) Since: 02/22/07 Posts: 5
|
I don't have
access to a
MySQL database
on the server I
will be
uploading the
website to.
That's why

|
Viewed: 17,483 Times | |  |
ki |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 10:05 pm on Feb 22 2007
|
|
|
 Member #: 204 Rank: user - (50) Since: 09/16/06 Posts: 53 From: Florida
|
okay try
posting the
smiles before
you write the
file 
|
Viewed: 17,478 Times | |  |
earth4x |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 10:18 pm on Feb 22 2007
|
|
|
Member #: 283 Rank: user - (5) Since: 02/22/07 Posts: 5
|
ki
said...
<
i>
okay try
posting the
smiles before
you write the
file
hey thanks
alot!! that
worked!!!
|
Viewed: 17,475 Times | |  |
earth4x |
Subject: "re: Need some
help building a
chat ..."
Posted: @ 9:09 pm on Feb 25 2007
|
|
|
Member #: 283 Rank: user - (5) Since: 02/22/07 Posts: 5
|
I still can't
find a way to
make the users
work without a
mysql
database...
as of right
now, I can
display the
users.. but
everytime the
page refreshes,
they
reappear!!!
if
(isset($user)){
// user is
$_SESSION['use
rname']
$fileN="
users.php"
;;
$file =
fopen($fileN,&
quot;a"
$txt =
fwrite($file,&
quot;$user<b
r>" ;
fclose($file);
}
what i'm
trying to do is
take each user,
put them in an
array, and
after that,
make a foreach
so each user
get displayed.
I also want to
remove a user
from the list
when he hasn't
typed anything
for the past 5
minutes.. but
i'm
stuck!!!
Any help would
be appreciated!
|
Viewed: 17,401 Times | |  |
Viewing Page: 1 of 1 |
|
|
|