Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

quotations

Contributor ,
Feb 08, 2007 Feb 08, 2007
hey guys. I am trying to get this quotation to work, i changed file / folder permitions to '646' CODE but when i open add_quote.php and submit a message here : http://therainbowpride.com/myphptests/add_quote.php i get this error :

Warning: fopen(../quotes.txt): failed to open stream: Permission denied in /home/therainb/public_html/myphptests/add_quote.php on line 20

Your quotation could not be stored due to a system error.



this is my php code :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add A Quotation</title>
</head>
<body>
<?php // Script 11.1 - add-quote.php
// This script displays and handles an HTML form.
// This script takes text input and stores it in a text file.

// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

if (isset ($_POST['submit'])) { // Handle form.

if ( !empty ($_POST['quote']) ) { // Check for the requiered value.

if ($fp = fopen ('../quotes.txt', 'ab')) { // Try to open file.

// Adjust for magic quotes.
if (ini_get ('magic_quotes_gpc')) {
$data = stripslashes ($_POST['quote']);
} else {
$data = $_POST['quote'];
}

fwrite ($fp, "$data\n"); // Write the data. Use \r\n on Windows.
fclose ($fp); // Close the file.

// Print a message.
print "<p>Your quotation has been stored.</p>";

} else { // Could not open the file.
print "<p>Your quotation could not be stored due to a system error.</p>";
}
} else { // Failed to enter a quotation.
print "<p>Please enter a quotation!</p>";
}

} // End of SUBMIT IF.

// Leave PHP and display the form.
?>

<form action="add_quote.php" method="post">
<p>
<textarea name="quote" rows="5" columns="30">Enter your quotation here.</textarea>
<br />
<input type="submit" name="submit" value="Add This Quote!" />
</p>
</form>
</body>
</html>


Can someone help me out? I can seem to find where the error is at .
Thank you so much
TOPICS
Server side applications
410
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 08, 2007 Feb 08, 2007
LuisDesigns wrote:
> hey guys. I am trying to get this quotation to work, i changed file / folder
> permitions to '646' CODE but when i open add_quote.php : and type a message i
> get this error :
> Warning: fopen(../quotes.txt): failed to open stream: Permission denied in
> /home/therainb/public_html/myphptests/add_quote.php on line 20


It's a permissions error. 4 is read only. Try 666.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 08, 2007 Feb 08, 2007
i changed it to 666 and still get the same error.
is this normal ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 08, 2007 Feb 08, 2007
ok, i got it to work. i dont know if this is normal , but i had to change this :

it was : if ($fp = fopen ('../quotes.txt', 'ab')) { // Try to open file.

and i removed the ../ leaving as ('quotes.txt') and it worked.

is it normal?

thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 09, 2007 Feb 09, 2007
LuisDesigns wrote:
> and i removed the ../ leaving as ('quotes.txt') and it worked.
>
> is it normal?

If the text file is in the same folder as the script, of course it's normal.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 09, 2007 Feb 09, 2007
LATEST
ok, thanks you so much
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines