»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 04-05-2004, 01:09 PM   #1 (permalink)
Registered User
 
Join Date: Nov 2003
Posts: 34
Andybebad is on a distinguished road

I'm trying to make my own shoutbox using php. The two files are
shout.php and shouting.php. Shout is where you make a new message and shouting is what adds your message to shout. But when I try to run it, I get Parse error: parse error in /data/hosted/simpsonsdungeon/shouting.php on line 9. Here are the two codes:
PHP Code:
<FORM METHOD="POST" ACTION="shouting.php">
Your Name<BR><INPUT TYPE="text" NAME="name"><br>
Message:<br>
<
TEXTAREA NAME="Message">
</
TEXTAREA>
<
INPUT TYPE="submit" VALUE="Make it real">
</
FORM
and
PHP Code:
<?php

     
     $path 
"shout.php";

     
     
fopen("$path""w+");

     
$Data = <?php echo $_POST["name"]; ?>"<br>"<?php echo $_POST["Message"]>;

     
$currentdata fread("$path""100");

     
     
fwrite("$Data");

     
     
fclose("$path");

?>
<a href="/shout.php">Go Back</a>

Andybebad is offline   Reply With Quote
Old 04-05-2004, 01:17 PM   #2 (permalink)
Registered User
 
Carl-cox-'s Avatar
 
Join Date: Nov 2002
Location: Kent England
Posts: 235
Carl-cox- is on a distinguished road
i dont understand how are you storeing the data then getting it to appear on the page again

Are you only allowing one shout to be shown at a time ?

also whihc line is line 9
Carl-cox- is offline   Reply With Quote
Old 04-05-2004, 03:04 PM   #3 (permalink)
Registered User
 
Join Date: Nov 2003
Posts: 34
Andybebad is on a distinguished road
line 9 is $Data = <?php echo $_POST["name"]; ?>"<br>"<?php echo $_POST["Message"]>;

How would I make it so it shows more than one post
Andybebad is offline   Reply With Quote
Old 04-05-2004, 04:07 PM   #4 (permalink)
Registered User
 
Carl-cox-'s Avatar
 
Join Date: Nov 2002
Location: Kent England
Posts: 235
Carl-cox- is on a distinguished road
$Data = '<?php echo $_POST["name"]; ?>"<br>"<?php echo $_POST["Message"]>;'

i think that will work it will treat the whole line as one string then when its inputted into the new page it will work.

to get multiple shouts in the shout box you need to store the shouts in a database you can use a text file tho. basically its teh same but

PHP Code:
<?

$db_filename 
"shoutsdb.txt";
$string_to_add '<b>'.$_POST["name"].':</b><br>'.$_POST["Message"].'\n';

$handle fopen($db_filename'a');
fwrite($handle$string_to_add);
fclose($handle);
?>
Thats to add it to the database to get the data and get the shouts use another script

PHP Code:

<?
$show_shouts 
10;
$db_filename "shoutsdb.txt";
$handle = @fopen($db_filename'r'); 

 
$array explode("\n"fread($fpfilesize($db_filename))); 
$i 0;

foreach (
$array as $shout){
if (
$show_shouts){
exit;
}else{
echo 
$shout;
}
i++;
}
?>
if your feeling more adventuroius you can do a mysql one

http://www.oxyscripts.com/php/tutorials/17/0.php

Last edited by Carl-cox-; 04-05-2004 at 04:11 PM.
Carl-cox- is offline   Reply With Quote
Old 04-05-2004, 06:51 PM   #5 (permalink)
Registered User
 
Join Date: Nov 2003
Posts: 34
Andybebad is on a distinguished road
My host dosn't have mysql but thanks for the help!

EDIT: I get parse error on line 15 with
<?
$show_shouts = 10;
$db_filename = "shoutsdb.txt";
$handle = @fopen($db_filename, 'r');

$array = explode("\n", fread($fp, filesize($db_filename)));
$i = 0;

foreach ($array as $shout){
if (i > $show_shouts){
exit;
}else{
echo $shout;
}
i++;
}
?>

Which would be i++;

Last edited by Andybebad; 04-05-2004 at 06:56 PM.
Andybebad is offline   Reply With Quote
Old 04-06-2004, 11:52 AM   #6 (permalink)
Registered User
 
Carl-cox-'s Avatar
 
Join Date: Nov 2002
Location: Kent England
Posts: 235
Carl-cox- is on a distinguished road
mmm subtitute i++ for

i = i + 1;
Carl-cox- is offline   Reply With Quote
Old 04-16-2004, 03:40 AM   #7 (permalink)
Registered User
 
Join Date: Apr 2004
Location: Philippines
Posts: 8
marie_selle is on a distinguished road
hi let me give it a try....

in line 9: $Data = <?php echo $_POST["name"]; ?>"<br>"<?php echo $_POST["Message"]>;

it is suppose to be like this: ('?' is missing)
$Data = <?php echo $_POST["name"]; ?>"<br>"<?php echo $_POST["Message"]?>;

in line 15:
i++;
try changing it to "i += 1;"
marie_selle is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 07:56 PM.