Jump to content

PHP Include problem


iandotcom

Recommended Posts

Hey,

 

I made a commenting app for my website, and I'm having problems with the include for it to be embedded on its parent page.

 

	<?php

	include ("../iandotcom/comments/comments.php?id=1");		

	?>

 

Its probably really simple, I'm quite new to PHP. I'm running this off my localhost, so thats the root.

Link to comment
Share on other sites

Same result :(

 

Heres the error message when it fails:

 

Warning: include(../iandotcom/comments/comments.php?id=1) [function.include]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\iandotcom\about\index.php on line 79

 

Warning: include() [function.include]: Failed opening '../iandotcom/comments/comments.php?id=1' for inclusion (include_path='.;C:\Program Files\xampp\php\pear\') in C:\Program Files\xampp\htdocs\iandotcom\about\index.php on line 79

Link to comment
Share on other sites

failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\iandotcom\about\index.php on line 79

 

You need to read and interpret the errors you receive if you want to excel as a developer.  This is telling you that the file you are trying to include does not exist.

 

"But it does exist!" you say.  "I can see it in windows explorer!"

 

Well, in that case you're probably using the wrong path.

 

<?php
include ("./comments/comments.php?id=1");
?>

Link to comment
Share on other sites

i believe include and require (and their variants) use the filesystem to include the file so when you pass _GET variables, it will probably search the file system for a file with that name,

 

 

your code probably is looking for a file named 'comments.php?id=1' but only 'comments.php' exists.

 

 

you'd typically use include or require if you want to include the raw PHP code to be processed on the page.

 

you could try this:

<?php
$_GET['id'] = 1;
include ("../iandotcom/comments/comments.php");		
?>

 

 

that might work for you if your code looks for a _GET['id'] to process whatever it is you are processing.

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.