0

I ma having this code

<?php include ("commentsdisplay.php?postid=".$activity[$i]['PostId']."&category=".$activity[$i]['Category']) ; ?>

but php is generating a fatal error. Is this syntax wrong?

 Warning: include(commentsdisplay.php?postid=17&amp;category=article): 
 failed to open stream: No error in C:\wamp\www\Spiralblog\home.php on line  
 79
 Call Stack
 #  Time    Memory  Function    Location
 1  0.0015  253760  {main}( )   ..\home.php:0
whatever
  • 332
  • 2
  • 16

1 Answers1

1

You can't pass parameters to an include like that.

Read the first answer on this question posted a while ago: https://stackoverflow.com/a/1232114/4296515

Quote from : @Daff

Imagine the include as what it is: A copy & paste of the contents of the included PHP file which will then be interpreted. There is no scope change at all, so you can still access $someVar in the included file directly (even though you might consider a class based structure where you pass $someVar as a parameter or refer to a few global variables).

Community
  • 1
  • 1
Gerton
  • 676
  • 3
  • 14
  • aha!!!! but what if I want to reuse the page somewhere else??? as you can see its the comments display page.. and I want to reuse the code in places where there is a need for the comments to be displayed.. so if I follow what is in that previous answer then the code will be bound only to one place.. – whatever May 08 '15 at 13:52
  • Well, to answer that question we'd need a lot more info like what framework you're using, how you're building your HTML etc. so you might want to create another question for that purpose. – Gerton May 08 '15 at 13:56