Chezshire Posted June 22, 2010 Share Posted June 22, 2010 Hello to one and all, newbie/hobbiest here - I am attempting to adjust the mail function in my scripts so that rather then having to constantly update 30 different scripts I can have one text doc that they can all draw on using the file_get_contents function to read in the email address as a string and send the notices to those email address, however I am getting an error when I attempt this which reads as follows: Warning: file_get_contents(email_addressestxt) [function.file-get-contents]: failed to open stream: No such file or directory in /home/maxster/xaviers-children.net/modMail/charRequest.php on line 2 $emailAddresses = file_get_contents(email_addresses.txt); $to = $emailAddresses; [\code] Error produced: Warning: file_get_contents(email_addressestxt) [function.file-get-contents]: failed to open stream: No such file or directory in /home/maxster/xaviers-children.net/modMail/charRequest.php on line 21 text file being read: [code] Ditko <chezshire@gmail.com>, Bill<example@example.com> Full Php Script: <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Xavier's Children » Character Request Sent!</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body align="center"> <h2 align="center">Xavier's Children » Character Request Sent!</h2> <?php $name = $_POST['namePlayer']; $topic = $_POST['nameTopic']; $char_overview = $_POST['charOverview']; $char_requested = $_POST['charRequested']; $email = $_POST['email']; $oc_fc = $_POST['OcFc']; //$emailAddresses = file_get_contents(email_addresses.txt); //$to = $emailAddresses; $to = 'ADAMS <doyleconlan@ireland.com>, DITKO <chezshire@gmail.com>, VAUGHAN <vismaior2000@yahoo.com>'; $subject = 'Xavier\'s Children » Character Request ' . $oc_fc . ' - ' . $char_requested; $msg = "FROM: $name \n \n"; $msg .= (empty($oc_fc)) ? "" : "OC or FC: $oc_fc \n \n"; $msg .= (empty($char_requested)) ? "" : "CHARACTER NAME: $char_requested \n \n"; $msg .= "CHARACTER OVERVIEW: $char_overview \n \n"; mail($to, $subject, $msg, 'From:' . $email); echo 'Your petition to play <strong>' . $char_requested . '</strong> has been submitted and forward to the appropriate member\'s staff members ' . $name . '. Please allow us to review and consider your request. We will attempt to contact you with a decision within twenty-four hours.<br /> <br />'; ?> <p align=center><a href=../messages.php>RETURN TO XAVIER'S CHILDREN</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/ Share on other sites More sharing options...
premiso Posted June 22, 2010 Share Posted June 22, 2010 Well given the error: Warning: file_get_contents(email_addressestxt) I would say you are missing a . in your actual code before the txt. Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/#findComment-1075565 Share on other sites More sharing options...
Chezshire Posted June 22, 2010 Author Share Posted June 22, 2010 Hmms, So should I change this line of code: $emailAddresses = file_get_contents(email_addresses.txt); to this: $emailAddresses = file_get_contents(email_addresses.\txt); There is a period in the line of code - is that causing a concatenation thus erring out script? -Chez Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/#findComment-1075569 Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2010 Share Posted June 22, 2010 You are missing quotes around the file name, making php think it is a defined constant (if error reporting was set to E_ALL you would see some notice messages alerting you to this problem.) Edit: Specifically - Notice: Use of undefined constant email_addresses - assumed 'email_addresses' in your_file.php on line x Notice: Use of undefined constant txt - assumed 'txt' in your_file.php on line x Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/#findComment-1075573 Share on other sites More sharing options...
Chezshire Posted June 22, 2010 Author Share Posted June 22, 2010 So I should change this line of code: $emailAddresses = file_get_contents(email_addresses.txt); to this: $emailAddresses = file_get_contents("email_addresses.txt"); Am i understanding you correctly? Thank you very much for the help -Chez Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/#findComment-1075575 Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2010 Share Posted June 22, 2010 Did you try that to see if it worked or not? One of the points of programming is you can try ideas and immediately observe the results to learn if your idea was correct or not. You don't need to wait around in a programming forum to learn answers to basic questions like that. Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/#findComment-1075609 Share on other sites More sharing options...
Chezshire Posted June 23, 2010 Author Share Posted June 23, 2010 Yes I did test it, but it didn't appear to work. But following the guidance provided here, I looked at my text file being read in and realized I had some quote marks in the text file what was causing my script to error out. Thank you everyone -Chez Quote Link to comment https://forums.phpfreaks.com/topic/205550-file_get_contents-doesnt-seem-to-get-the-file-contents-help/#findComment-1076051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.