Php include statement doesn't work for me.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Php include statement doesn't work for me.

Post by quadoc »

I've an include statement like include ("test.php"), but some how when I tested it it doesn't seem to include the file. Does anyone have any ideas? I'm using php ver. 5.2. Thanks...
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

What is the error message?
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Re: Php include statement doesn't work for me.

Post by dibyendrah »

quadoc wrote:I've an include statement like include ("test.php"), but some how when I tested it it doesn't seem to include the file. Does anyone have any ideas? I'm using php ver. 5.2. Thanks...
Try printing some message in included files.

Like

Code: Select all

test.php

Code: Select all

<?php
print "Test Message...";
?>

Code: Select all

file.php

Code: Select all

<?php
include("test.php");
?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

most common problems:
- include_path does not included the working directory (.)
- webserver doesn't have rights to read the file
- the 'included' file contains php code that is not surrounded by <? ?>
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


ok, this is pretty weird!  Before the upgrade to 5.2 upgrade, I can mixed match my code with html code like the xample below, but now it's not working any more.  I've to echo those html code in order for it to work.  Does anyone know why?  Thanks...

Code: Select all

<?php

   if(isset($index) != 1)
     {
 
        die("Please contact admin.");

     } else {}


?>

<table width="600" border="0" align="center" cellpadding="1" cellspacing="1">
  <tr align="left" valign="top"> 
 <td colspan="4">';

<?

   if(isset($index) != 1)
     {
       die("Please contact admin.");
     }
?>

</table>

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Don't use short tags (<?), change to <?php
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

astions nailed it for your I believe. That is like the third or fourth short tags related problem posted here in the last two days. Seems to be turning into an epidemic.

If I could ask, what is this little beauty supposed to do:

Code: Select all

<?php

   if(isset($index) != 1)
     {
 
        die("Please contact admin.");

     } else {}


?>
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

Thanks for the info. everyone. The code was just an example. Also, when I click on the "Code" button in the post a reply, it doesn't insert the tag for me. It it not working? Could someone check into that.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

works for me

Code: Select all

works as well
ie7/vista
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

So is there a way that I can set some switches that will work with the "<?" or do I have to change every occurences of "<?" to "<?php", does anyone know? Thanks... :(
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You can change your php.ini file, but I am almost certain that short tags are deprecated in PHP6, which means at some point you will need to change your code in order to run properly. Now is as good a time as any.
Post Reply