kjetterman Posted November 20, 2012 Share Posted November 20, 2012 Here is the code that I wrote: $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br />". include('testsite/includes/usermain/successpage.php') ." "; The problem is, it is throwing an error because of this line: include('testsite/includes/usermain/successpage.php') Here are the errors: Warning: include(testsite/includes/usermain/successpage.php ) [function.include]: failed to open stream: No such file or directory in /home/xxxx/public_html/testsite/photog_main.php on line 1976 Warning: include() [function.include]: Failed opening 'testsite/includes/usermain/successpage.php ' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxx/public_html/testsite/photog_main.php on line 1976 From what I have read, this is a php.ini issue. So, I will need to change the server settings to Allow_url_include = yes and allow_url_fopen = yes. I can do this but I understand that to make these changes means a security risk. Is there anyway around this? TIA for any help or guidance you can offer! Quote Link to comment Share on other sites More sharing options...
requinix Posted November 20, 2012 Share Posted November 20, 2012 (edited) From what I have read, this is a php.ini issue. So, I will need to change the server settings to Allow_url_include = yes and allow_url_fopen = yes. Nope. The problem is what's stated in the error message: "No such file or directory". Since the script is in testsite/ you told PHP to look for the file in testsite/testsite/includes/usermain/successpage.php... [edit] As for the INI settings, allow_url_include is a problem and you should never use it. However allow_url_fopen is very useful to have so do enable that, and actually by itself it's hard to use insecurely. Edited November 20, 2012 by requinix Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2012 Share Posted November 20, 2012 Also, since that's a file system path and not a URL, the two settings having to do with using include statements with URLs would have no effect on the problem. Quote Link to comment Share on other sites More sharing options...
kjetterman Posted November 20, 2012 Author Share Posted November 20, 2012 requinix, thank you for your response!! I changed the code slightly. I took off /testsite/includes on the url and now have includes/usermain... $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br />". include('includes/usermain/successpage.php') ." "; I get this error... Warning: include(includes/usermain/successpage.php ) [function.include]: failed to open stream: No such file or directory in /home/xxxx/public_html/testsite/photog_main.php on line 1976 Warning: include() [function.include]: Failed opening 'includes/usermain/successpage.php ' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxx/public_html/testsite/photog_main.php on line 1976 Quote Link to comment Share on other sites More sharing options...
Jessica Posted November 20, 2012 Share Posted November 20, 2012 Rather than removing the testsite part, I think you need to add /home/xxxx/public_html/testsite/ to the beginning. You're sure that the file is in the folder you're looking in? Quote Link to comment Share on other sites More sharing options...
kjetterman Posted November 20, 2012 Author Share Posted November 20, 2012 (edited) Thank you for your response, Jessica! Yes, I put the file in the includes/usermain folder on the server. Here is the path: http://diocesan.com/...successpage.php $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br />". include('home/xxxx/public_html/testsite/includes/usermain/successpage.php') ." "; I get this error message: Warning: include(home/xxxx/public_html/testsite/includes/usermain/successpage.php ) [function.include]: failed to open stream: No such file or directory in /home/xxxx/public_html/testsite/photog_main.php on line 1976 Warning: include() [function.include]: Failed opening 'home/xxxx/public_html/testsite/includes/usermain/successpage.php ' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxx/public_html/testsite/photog_main.php on line 1976 I tried changing the url in the code to this also -- /home/xxxx/public_html/testsite/includes/usermain/successpage.php Got the same errors above but just with the '/' in front of "home" (if that makes sense). Edited November 20, 2012 by kjetterman Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2012 Share Posted November 20, 2012 Is the photog_main.php file being mentioned in the error the actual main file being requested? Or is it something like yourdomain.com/index.php and index.php is including photog_main.php? The reason I ask is that relative include files are relative to the main file (the current working directory) and not a file that has been included itself. Also, did you replace the xxxxx with your actual dioce2 path (btw these are NOT url's, they are file system paths.) Quote Link to comment Share on other sites More sharing options...
kjetterman Posted November 20, 2012 Author Share Posted November 20, 2012 index.php does not include photogmain.php. index.php shows one thing... photogmain.php shows another (in the body of the site). I didn't replace the actual path with xxx at least, not in the code.... just in the post... Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 20, 2012 Share Posted November 20, 2012 (edited) Maybe this is a stupid question, but I see you are using the include() within a string concatenation for an assignment. You "can" create an include file to return data, but that is not a very common use of include files. So, did you set up that include file to "return" data rather rather than "echoing" it? If not, it will not work how you expect it - once you get the errors resolved. Edited November 20, 2012 by Psycho Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted November 20, 2012 Share Posted November 20, 2012 Maybe this is a stupid question, but I see you are using the include() within a string concatenation for an assignment. You "can" create an include file to return data, but that is not a very common use of include files. So, did you set up that include file to "return" data rather rather than "echoing" it? If not, it will not work how you expect it - once you get the errors resolved. Agreed. I am assuming she will be echo'ing $statusMessage at some point. @kjetterman: The basic logic for returning a "success" page could be the following: if (something was successful) { include('successpage.php'); } else { include('error_page.php'); } That is extremely basic, pseudo code. But since you are not going that path, why don't you not include the success page and just code it inline, within the $statusMessage variable? Looks like your successpage.php is only a few lines of code, anyway. Quote Link to comment Share on other sites More sharing options...
kjetterman Posted November 21, 2012 Author Share Posted November 21, 2012 (edited) Thanks for all of the help everyone! I really appreciate it! Here's a puzzle (well for me... maybe not for you guys...lol ) $statusMessage is a variable used for many strings. Here is what I am talking about: $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br />". include('includes/usermain/successpage.php') ." "; } } else $statusMessage = "<fieldset><img src=\"dImages/fail.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Error!</b></font><br>There was an internal error while trying to upload the file, please try again.</b></fieldset>"; } else $statusMessage = "<fieldset><img src=\"dImages/fail.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Error!</b></font><br>There was an internal error while trying to upload the file, please try again.</b></fieldset>"; } else $statusMessage = "<fieldset><img src=\"dImages/fail.gif\"> <font color=\"#CC0000\" size=\"3\"><b>The selected file is too small.</b><br>Use the Browse... button to select the file you would like to send.</font></fieldset>"; } echo $statusMessage; Now, if I structure the code like this: $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br />"; include('includes/usermain/successmessage.php'); } It works but is positioned below the $statusMessage string. So, the problem is in the positioning. I want the image (which is basically what is contained in successmessage.php), to be at the end of the first $statusMessage string but in between the quotes so that it will position below the string visually on the site. So the status message string needs to come first and then the image. Does that make sense? I don't believe I can upload an image yet, otherwise I would give you a visual of what I am talking about. Edited November 21, 2012 by kjetterman Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted November 21, 2012 Share Posted November 21, 2012 As I mentioned, you could just simply add the image to the existing $statusMessage variable, like so: <?php $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br /><a href=\"holidaycalendar.php\"><img src=\"/images_common/web_cal_christmas_2012.png\" alt=\"Christmas Calendar\" /></a><a href=\"/files_common/MI_cal_2012.pdf\"><img src=\"/images_common/print_button2.gif\" width=\"560\" height=\"37\" border=\"0\" style=\"margin-bottom: 20px;\" /></a>"; Quote Link to comment Share on other sites More sharing options...
kjetterman Posted November 21, 2012 Author Share Posted November 21, 2012 (edited) As I mentioned, you could just simply add the image to the existing $statusMessage variable, like so: <?php $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br /><a href=\"holidaycalendar.php\"><img src=\"/images_common/web_cal_christmas_2012.png\" alt=\"Christmas Calendar\" /></a><a href=\"/files_common/MI_cal_2012.pdf\"><img src=\"/images_common/print_button2.gif\" width=\"560\" height=\"37\" border=\"0\" style=\"margin-bottom: 20px;\" /></a>"; That is what I ended up doing. It was much easier that way and less hassle! I think ... I was making things harder than they needed to be. Completed code: $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.<br /><a href=\"http://diocesan.com/testsite/holidaycalendar.php\"><img src=\"/images_common/web_cal_christmas_2012.png\"></a><a href=\"http://diocesan.com/files_common/MI_cal_2012.pdf\"><img src=\"/images_common/print_button2.gif\"></a><br /></fieldset>"; Thank you to everyone who helped in this thread! My goal is to get better at this and learn everything I can. So again, thank you all for being awesome!! Edited November 21, 2012 by kjetterman Quote Link to comment Share on other sites More sharing options...
Jessica Posted November 24, 2012 Share Posted November 24, 2012 You may want to look into templating, it might help you accomplish stuff like this later on. Quote Link to comment 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.