What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Shoutbox help

Pages: (4): « First [ 1 ] 2 3 4 » Last »
PHP Shoutbox help
Author: Message:
M73A
Veteran Member
*****

Avatar


Posts: 3213
Reputation: 37
34 / Male / Flag
Joined: Jul 2004
O.P. PHP Shoutbox help
i've got this script for a shoutbox off of hotscripts.. i just wondered if it was possible to have the php insert a new line (on the top of the .txt file) and put the new shouts ontop, so older ones are at the bottom.

Its a simple script that adds whats entered into the text input bit onto the end of the .txt file..

any ideas?

Thanks

p.s. shall i post the code?

[Image: lost7ru.gif]
06-08-2007 06:05 PM
Profile E-Mail PM Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: PHP Shoutbox help
I wish to see the code to understand what you mean. :)
4 8 15 16 23 42
06-08-2007 06:14 PM
Profile E-Mail PM Find Quote Report
toddy
Veteran Member
*****

Avatar
kcus uoy

Posts: 2573
Reputation: 49
– / Male / Flag
Joined: Jun 2004
RE: PHP Shoutbox help
why would you want new shouts at the top??
you'd have to have the input field at the top too, other wise u would mean that you'd have to view it on full window, or keep scrolling down to add new shouts.

This post was edited on 06-08-2007 at 06:24 PM by toddy.
06-08-2007 06:22 PM
Profile PM Find Quote Report
M73A
Veteran Member
*****

Avatar


Posts: 3213
Reputation: 37
34 / Male / Flag
Joined: Jul 2004
O.P. RE: PHP Shoutbox help
quote:
Originally posted by toddy
why would you want new shouts at the top??
you'd have to have the input field at the top too, other wise u would mean that you'd have to view it on full window, or keep scrolling down to add new shouts.
yeah i managed to move the input field at the top too:P

i want the new ones ontop so i dont have to keep clearing it if it gets to long, it will just scroll for ages but the newest ones will be on view :)

heres the indexy one
code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body style="overflow-x:hidden;overflow-y:scroll;">

<//------- Start copying from this point -------->

<table class="shoutBox">
<tr><td class="shoutBox">
<p class="heading"><b>.:: ShoutBox ::.</b></p>
<p>
<center>
<form name="shoutForm" method="POST" action="addShout.php">
Name: <input type="text" name="user" size="15"><br>
Shout: <input type="text" name="shout" size="15"><br>
<input type="submit" value="Send!">
</center>
<hr>
<?php

  $fp = fopen("shouts.txt","r");
  while(($shout = fgetcsv($fp,1000,":")) !== FALSE) {
   
     echo "<b>".$shout[0]." : </b>".$shout[1]."<br>";
  }

  fclose($fp);
?>
</p>

</form>
</td></tr>
</table>

<//------- Finish copying from this point -------->

</body>
</html>






And heres the 'Add shout.php' one

code:
<?php

  /* -------------------------------------------------------

                           ShoutBox v1.1
                     By: Mark Lethbridge, 2007

     -------------------------------------------------------

     Install notes:
     Only thing that needs to be changed in this file is the
     line: $shoutbox_page = "index.php";
     You simple change "index.php" into the correct page
     that the shoutbox will appear in.

     -------------------------------------------------------- */

   $fp = fopen("shouts.txt","a");
   fwrite($fp,$_POST['user'].":".$_POST['shout']."\n");
   fclose($fp);
   $shoutbox_page = "http://pps3.awardspace.com/Shoutbox/index.php";
   header("Location: $shoutbox_page");

?>

[Image: lost7ru.gif]
06-08-2007 06:33 PM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: PHP Shoutbox help
Why dont you just use a mysql one?
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-08-2007 06:35 PM
Profile E-Mail PM Web Find Quote Report
M73A
Veteran Member
*****

Avatar


Posts: 3213
Reputation: 37
34 / Male / Flag
Joined: Jul 2004
O.P. RE: PHP Shoutbox help
quote:
Originally posted by Napbree
Why dont you just use a mysql one?
free hosting account etc, didnt really want to use up the mysql database just for a shoutbox

[Image: lost7ru.gif]
06-08-2007 06:37 PM
Profile E-Mail PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
RE: PHP Shoutbox help
You would use 1 table in that database.  Not a big deal.
Touch Innovation - touch friendly programs/applications for the windows mobile!


06-08-2007 06:49 PM
Profile E-Mail PM Web Find Quote Report
M73A
Veteran Member
*****

Avatar


Posts: 3213
Reputation: 37
34 / Male / Flag
Joined: Jul 2004
O.P. RE: PHP Shoutbox help
quote:
Originally posted by Napbree
You would use 1 table in that database.  Not a big deal.
well i still want to use this one so how can i make it new ontop :P

[Image: lost7ru.gif]
06-08-2007 06:54 PM
Profile E-Mail PM Find Quote Report
Veggie
Full Member
***

Avatar

Posts: 415
Reputation: 21
37 / Male / Flag
Joined: Sep 2004
RE: PHP Shoutbox help
code:
<?
$file='file.txt';
$newcontent = 'blah';
$new = $newcontent . "\n" . file_get_contents($file);
$fp =fopen($file,'w');
fwrite($fp, $new);
fclose($fp);

?>

you cant use fopen to write to the top without over writing. Use this to get the file contents add it to the end of the new string then save

This post was edited on 06-08-2007 at 07:13 PM by Veggie.
06-08-2007 07:13 PM
Profile E-Mail PM Web Find Quote Report
M73A
Veteran Member
*****

Avatar


Posts: 3213
Reputation: 37
34 / Male / Flag
Joined: Jul 2004
O.P. RE: PHP Shoutbox help
lol sorry, im a complete php newb... where about would it have to go, and in what one, lol

quote:
Originally posted by M73A
s the 'Add shout.php' one

    code:
    <?php

      /* -------------------------------------------------------

                               ShoutBox v1.1
                         By: Mark Lethbridge, 2007

         -------------------------------------------------------

         Install notes:
         Only thing that needs to be changed in this file is the
         line: $shoutbox_page = "index.php";
         You simple change "index.php" into the correct page
         that the shoutbox will appear in.

         -------------------------------------------------------- */

$file='file.txt';
$newcontent = 'blah';
$new = $newcontent . "\n" . file_get_contents($file);
$fp =fopen($file,'w');
fwrite($fp, $new);
fclose($fp);

       fwrite($fp,$_POST['user'].":".$_POST['shout']."\n");
       fclose($fp);
       $shoutbox_page = "http://pps3.awardspace.com/Shoutbox/index.php";
       header("Location: $shoutbox_page");

    ?>






----------->Click Here To Sign Up To Nintendo.com VIP<-----------

like that?

This post was edited on 06-08-2007 at 07:15 PM by M73A.

[Image: lost7ru.gif]
06-08-2007 07:14 PM
Profile E-Mail PM Find Quote Report
Pages: (4): « First [ 1 ] 2 3 4 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On