Jump to content

parsing URL variables in the include


Q695

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/146599-parsing-url-variables-in-the-include/
Share on other sites

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

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.

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>

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);
?>

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.

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>

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;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.