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

 

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.