Q695 Posted February 23, 2009 Share Posted February 23, 2009 errors: Warning: include(bulletin.php?church=1) [function.include]: failed to open stream: No such file or directory in /home/sd52gop0/public_html/church/index.php on line 57 Warning: include(bulletin.php?church=1) [function.include]: failed to open stream: No such file or directory in /home/sd52gop0/public_html/church/index.php on line 57 Warning: include() [function.include]: Failed opening 'bulletin.php?church=1' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/sd52gop0/public_html/church/index.php on line 57 the code that seems to be dieing is: include "bulletin.php?church=1"; the path is correct. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/ Share on other sites More sharing options...
The Little Guy Posted February 23, 2009 Share Posted February 23, 2009 you can't use get values through an include. you can only do this: include "bulletin.php"; You will have to have that in your address bar for it to work properly Eg: http://mysite.com/page.php?var1=123&church=1 Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769595 Share on other sites More sharing options...
Q695 Posted February 23, 2009 Author Share Posted February 23, 2009 What would I do instead of a get to parse the variables in an application? Why did it work with: <img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" alt="captcha" /> which can be found at: http://www.white-hat-web-design.co.uk/articles/php-captcha.php Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769624 Share on other sites More sharing options...
The Little Guy Posted February 23, 2009 Share Posted February 23, 2009 because you are not "Including" that image. You are making a separate HTTP call to the server. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769625 Share on other sites More sharing options...
trq Posted February 23, 2009 Share Posted February 23, 2009 What would I do instead of a get to parse the variables in an application? Why did it work with: <img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" alt="captcha" /> which can be found at: http://www.white-hat-web-design.co.uk/articles/php-captcha.php The reason the src tag works is because it makes another http request. Include does not. What you can do is.... $church = 1; include 'bulletin.php'; $church will then be available within bulletin.php. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769627 Share on other sites More sharing options...
Philip Posted February 23, 2009 Share Posted February 23, 2009 Because include is looking for the file "bulletin.php?church=1" not "bulletin.php" You could always do : <?php $bar = 'test'; include 'foo.php'; ?> in foo.php: <?php echo $bar; // echo's test ?> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769628 Share on other sites More sharing options...
Q695 Posted February 23, 2009 Author Share Posted February 23, 2009 What should the code read as in this then? <?php <?php $church=$_GET[church]; ?> <font face="Arial, Helvetica, sans-serif">On this page you will find our most recent weekly bulletins and newsletters.</font> <p><font face="Arial, Helvetica, sans-serif">To view the older bulletins you will need an Acrobat reader that you can get from <a target="_blank" href="http://www.adobe.com/products/acrobat/readstep2.html"> Adobe</a>.</font></p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Date</td> <td>Comments</td> </tr> <?php $sql="SELECT * FROM bulletin WHERE church='$church'"; $result=@mysql_query($sql,$con) or die(death($sql)); $row=mysql_fetch_array($result); ?> <tr> <td></td> <td></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769630 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 Any ideas on how to embed html in a page with variables in the address? Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769828 Share on other sites More sharing options...
Philip Posted February 24, 2009 Share Posted February 24, 2009 <?php $church = 1; include "bulletin.php"; ?> In bulletin.php, you can get rid of: <?php $church=$_GET[church]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769829 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 That is only on that page, not all the pages. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769854 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 That is only on that page, not all the pages. So, what is your question now? Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769855 Share on other sites More sharing options...
Philip Posted February 24, 2009 Share Posted February 24, 2009 Okay, then in bulletin.php: <?php if(!isset($church)) $church=$_GET['church']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769856 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 this is the code I currently have: <?php /** * Initialize the cURL session */ $ch = curl_init(); /** * Set the URL of the page or file to download. */ curl_setopt($ch, CURLOPT_URL, 'bulletin.php?church=1'); /** * Ask cURL to return the contents in a variable * instead of simply echoing them to the browser. */ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); /** * Execute the cURL session */ $contents = curl_exec ($ch); /** * Close cURL session */ curl_close ($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769857 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 And what is your question? Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769860 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 I'm trying to do an include "bulletin.php?church=$church"; that could be inside, or outside of the site. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769863 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 Maybe your looking for.... $file = file_get_contents("http://server.com/bulletin.php?church=$church"); ? You still don't seem to be actually explaining your problem or exactly what it is your trying to do. Your last comment made no sense to me at all. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769864 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 thorpe , can I do this with PDFs also to convert them to HTML? Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769866 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 Try it and see. file_get_contents simply reads an entire file into a string. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769869 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 I never knew that trick, so it should work Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769870 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 I just realized I need a little help debugging some of the script, what am I doing wrong with the symantics to load a bulletin: <?php print_r($_SERVER); include "link/dead.php"; include "link/log.php"; $church=$_GET[church]; $bulletin=$_GET[bulletin]; ?> <font face="Arial, Helvetica, sans-serif">On this page you will find our most recent weekly bulletins and newsletters.</font> <p><font face="Arial, Helvetica, sans-serif">To view the older bulletins you will need an Acrobat reader that you can get from <a target="_blank" href="http://www.adobe.com/products/acrobat/readstep2.html"> Adobe</a>.</font></p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Date</td> <td>Comments</td> </tr> <?php $sql="SELECT * FROM bulletin WHERE church='$church'"; $result=@mysql_query($sql,$con) or die(death($sql)); while ($row=mysql_fetch_array($result)){ ?> <tr> <td><a href="?page=bulletin&bulletin=<?php echo $row[id]; ?>"><?php echo $row[date];?></a></td> <td><a href="?page=bulletin&bulletin=<?php echo $row[id]; ?>"><?php echo $row[comments];?></a></td> </tr> <?php } if ($bulletin){ ?> <tr> <td colspan="2"><?php $sql="SELECT * FROM bulletin WHERE id='$bulletin'"; $result=@mysql_query($sql,$con) or die(death($sql)); $row=mysql_fetch_array($result); echo $row[text]; ?></td> </tr> <?php } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769884 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 Could be many things. Descibe your problem. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769885 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 it doesn't work at: http://sd52gop.internetkeep.net/church/?page=bulletin&bulletin=1 it works at: http://sd52gop.internetkeep.net/church/bulletin.php?page=bulletin&church=1&bulletin=1 Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769886 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 Describe your actual problem. Theres a link in my signiture Howto ask? that might help you. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-769946 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 It treats the page statically, not dynamically. Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-770298 Share on other sites More sharing options...
Q695 Posted February 24, 2009 Author Share Posted February 24, 2009 this case within the main switch statement may help: <?php case bulletin: if ($_GET[bulletin]){ $bulletin="&bulletin=$_GET[bulletin]"; } echo $bulletin; $file=file_get_contents("http://sd52gop.internetkeep.net/church/bulletin.php?church=$church$bulletin"); echo $file; break; ?> Quote Link to comment https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/#findComment-770338 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.