|
-
Jul 30th, 2006, 07:15 AM
#1
Thread Starter
Fanatic Member
creating comments on my server
Hi, im creating a txt from my web.. but when i check it in my cpanel why Comments isn't create?
this is the code.. when i test this from my localhost its working properly..
whats wrong with this?
PHP Code:
<table width="100%" height="100%">
<?php
// filename
$file = "Comments.txt";
// validate form
function form_validate () {
if (sizeof($_POST) < 1) return false;
foreach ($_POST as $name => $value) {
if (empty($name) || !isset($name)) {
return false;
}
}
return true;
}
function blank_replace ($str) {
return str_replace (" ","|",$str);
}
function stick_escape ($str) {
return str_replace ("|"," ",$str);
}
if (form_validate()) {
$fp = fopen ($file,"at");
fwrite ($fp,uniqid(rand(),true)."\t".blank_replace($_POST['name'])."\t".blank_replace($_POST['comment'])."\n");
fclose ($fp);
}
if (!file_exists($file)) {
echo "Here, no commments"; //sorry my bad english
} else {
$fp = fopen ($file,"r");
while ($info = fscanf ($fp,"%s\n%s\n%s\n\n")) {
list ($id,$name,$comment) = $info;
?>
<table border="1" width="47%">
<tr>
<td width="26%">Name : </td>
<td width="74%"><?=stick_escape($name)?></td>
</tr>
<tr>
<td width="26%">Comment:</td>
<td width="74%"><?=stick_escape($comment)?></td>
</tr>
</table>
<br>
<?php
}
}
?>
<hr>
<form action="index.php" method="post">
Name :
<br>
<input name="name" type="text" size="30">
<br>
Comment :
<br>
<textarea cols="30" name="comment"> </textarea>
<br>
<input type="submit" value="Submit">
</form>
</table>
-
Jul 30th, 2006, 07:20 AM
#2
Re: creating comments on my server
-
Jul 30th, 2006, 07:39 AM
#3
Thread Starter
Fanatic Member
Re: creating comments on my server
that is a simple shout box.. i want the data save in txt format "Comments.txt"
when the user visited my site he will post the Name and Comments and if he press submit the data will record on comments.txt
br,
-
Jul 30th, 2006, 07:56 AM
#4
Re: creating comments on my server
Does your host support file I/O operations?
-
Jul 31st, 2006, 02:13 AM
#5
Re: creating comments on my server
You should check the file handle directly after opening it.
Also, the script should emit an error message if it can't open the file. If it doesn't, enable error reporting.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|