norwichchris Posted March 31, 2009 Share Posted March 31, 2009 hi i downloaded this script as an example from: http://www.phptoys.com/e107_plugins/conten...hp?content.68.1and hosted it on athost.net the problem is i get these error messages: Warning: fopen(messages/20090331101804.txt) [function.fopen]: failed to open stream: Permission denied in /data/www/net.athost.vhosts/n/norwichchris.athost.net/public_html/images.php on line 67Warning: fwrite(): supplied argument is not a valid stream resource in /data/www/net.athost.vhosts/n/norwichchris.athost.net/public_html/images.php on line 68Warning: fwrite(): supplied argument is not a valid stream resource in /data/www/net.athost.vhosts/n/norwichchris.athost.net/public_html/images.php on line 69Warning: fwrite(): supplied argument is not a valid stream resource in /data/www/net.athost.vhosts/n/norwichchris.athost.net/public_html/images.php on line 70Warning: fclose(): supplied argument is not a valid stream resource in /data/www/net.athost.vhosts/n/norwichchris.athost.net/public_html/images.php on line 71CODE Below: <?php// CHANGE PARAMETERS HERE BEGIN $columns = 5; $senderName = 'chris pearce'; // Eg.: John's Postcards $senderEmail = 'chris@pearce.net'; // Eg.: john@postcard.com // Change only if you have problems with urls $postcardURL = 'http://'.$_SERVER['norwichchris.athost.net'].$_SERVER['images'];// CHANGE PARAMETERS HERE END// This function displays the available imagesfunction displayPhotos(){ global $columns; $act = 0; // Open the actual directory if ($handle = opendir("thumbs")) { // Read all file from the actual directory while ($file = readdir($handle)) { if (!is_dir($file)) { if ($act == 0) echo "<tr>"; echo "<td align='center'> <img src='thumbs/$file' alt='postcard' /><br/> <input type='radio' name='selimg' value='$file' /> </td>"; $act++; if ($act == $columns){ $act = 0; echo "</tr>"; } } } echo "</tr>"; } }?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><html><body> <?php if ( (!isset($_POST['submit'])) && (!isset($_GET['show'])) ) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center"> <?php displayPhotos(); ?> </table> <h2>Fill the form</h2> <table width="100%"> <tr> <td>Send to (email address):</td> <td><input type="text" name="email" size="30"/></td> </tr> <tr> <td>Message:</td> <td><textarea name="message" rows="10" cols="40"></textarea></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Send card!" name="submit"/></td> </tr> </table> </form> <?php } else if ( (isset($_POST['submit'])) && (!isset($_GET['show'])) ) { $pic = isset ($_POST['selimg']) ? $_POST['selimg'] : ''; $filename = date('YmdGis'); $f = fopen('messages/'.$filename.".txt","w+"); fwrite($f,$pic."\n"); fwrite($f,$_POST['email']."\n"); fwrite($f,htmlspecialchars($_POST['message'])."\n"); fclose($f); // Compose the mail$postcardURL = 'http://'.$_SERVER['norwichchris.athost.net'].$_SERVER['images'];$from = "From: $chris pearce <$chris@pearce.net>\r\n";$replay = "Reply-To: $senderEmail\r\n"; $params = "MIME-Version: 1.0\r\n";$params .= "Content-type: text/plain; charset=iso-8859-1\r\n";$mailtext = "You have just received a virtual postcard!\r\n\r\n" . "You can pick up your postcard at the following web address:\r\n" . "$postcardURL"."?show=$filename\r\n\r\n" . "We hope you enjoy your postcard, and if you do, " . "please take a moment to send a few yourself!\r\n\r\n" . "Regards,\r\n" . "Postcard Tutorial\r\n" . $postcardURL;// Send email @mail($_POST['email'],"You've received a postcard",$mailtext,$from.$replay.$params);?> <center> Your postcard was sended succesfuly!<br/><br/> <img src='images/<?php echo $pic; ?>' alt="postcard" /><br/><br/><br/> <?php echo nl2br(htmlspecialchars($_POST['message'])); ?></center> <?php } else if ( (!isset($_POST['submit'])) && (isset($_GET['show'])) ) { $file = isset($_GET['show']) ? $_GET['show'] : '' ;$content = file('messages/'.$file.".txt");$pic = $content['0'];unset ($content['0']);unset ($content['1']);$main = "";foreach ($content as $value) { $main .= $value;}?> <center>Your postcard!<br/><br/> <img src='images/<?php echo $pic; ?>' alt="postcard" /> <br/><br/><br/> <?php echo nl2br(htmlspecialchars($main)); ?> </center> <?php } ?> </body> Any help would be much appreciated Link to comment Share on other sites More sharing options...
i am java Posted March 31, 2009 Share Posted March 31, 2009 Warning: fopen(messages/20090331101804.txt) [function.fopen]: failed to open stream: Permission denied in /data/www/net.athost.vhosts/n/norwichchris.athost.net/public_html/images.php on line 67I have never really worked in this field of PHP, but if I am not mistaken, that could be because either:1. The CHMOD permission for said file is not high enough. (Usually must be 777.)2. You didn't replace the "/data/www/net.athost.vhosts/n/norwichchris.athost.net/" part of it with your file directory.I could be wrong. But that should be it. Link to comment Share on other sites More sharing options...
norwichchris Posted March 31, 2009 Author Share Posted March 31, 2009 well here is the current URL for the site:http://norwichchris.athost.net/index.phpI don't know what CHMOD means? is that headers? Not sure what you mean there?, Also this was a test to see if the server i was using actually works or not with emails. I had a huge amounts of problems finding a easy to use testing server. -chris Link to comment Share on other sites More sharing options...
i am java Posted March 31, 2009 Share Posted March 31, 2009 It's the file permissions. It's changeable through your FTP program and, in some cases, your control panel. Link to comment Share on other sites More sharing options...
norwichchris Posted April 1, 2009 Author Share Posted April 1, 2009 I changed the CMOD settings for the server. Not sure what you meant by the last line? I also tried the program out on the wamp server i got no error messages but it still didn't work Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.