Ok I have looked trhough forums and mail archive and I cannot find anything like this.

What is happening is that when I use include or require it appears to include it just fine except for one thing. No data will be transfered. Meaning I cannot set a variable to like "hello world" and include it in antoher and print that variable. I do not get any errors and if I include a file that prints stuff it displays it fine. The only problem is if I set say a function or a variable the other script does not read it.

I have tryd chanigng safe mode to off ... nothing
I have tryd placing global $variable; ... nothing
I have checked to make sure globals were on... they are

So I am left puzzled as to what is the cause of this. I have never heard or seen this before.

Anyhelp would be greatly apreciated ty.

    Hey clandg, I am not sure what you are doing wrong, but this is generaly the way it should work.

    <?php // inctest.php
    
      $hello = "Hello World";
      include ("inc.php");
    
    ?>
    
    <?php // inc.php
    
      print $hello;
    
    ?>

    These two files together should print out "Hello World" into your browser. If you are running PHP in the file you are including, dont forget the <?php and ?>, those are often forgotten. If you are following all these rules, i would advise you post your code.

      <?php 
      //test1.php
      $test = "test";
      ?>
      <?php
      //test2.php
      include ("test1.php");
      print ("$test");
      ?>

      I've also tryed placing "global $test;" after the include.

        just for the heck of it why don't you use....

        echo $_POST['hello'];

        see if that works, then you are editing the wrong php.ini file.

        create a file called info.php

        <?
        phpinfo();
        ?>

        then run this script and about 5 lines down, it will show you where php is looking for the file. edit this file

          hmm well i tried that dont know why that would work and not the regular thing im doing... ofcourse i dont even know why its doing this in the first place.

          I have a php.php file that does that and thats where im seeing if safe mode or globals is on or off... it all seems fine.

          What are some of the things that could cause this? If I could get a list of them I could try and run through each one and iliminate them. So weird to see it include a file but not pass its data.

            <?php
            //test2.php
            include ("test1.php");
            print ("$test");
            ?>

            two things you can also try:

            take the space out from between include and (

            next instead of print....use echo to the file looks like this

            <?php
            //test2.php
            include("test1.php");
            echo $test;
            ?>
            I know the space doesn't mean anything...but we are debugging here 😉

              done... no cigar. The funny thing about this is it includes the file (like I said if the file its including says print bleh... bleh will appear).

              Man I want my site to be operational again (note its not the site i have for this account on these forums as that one is working fine)

                <?php 
                
                //test1.php
                
                $test = "test";
                
                ?>
                
                <?php
                
                //test2.php
                
                include ("test1.php");
                
                print ("$test");
                
                ?>
                

                Are you saying that that doesn't work? It works for me...

                Diego

                  did you just reinstall php????

                  if so, I might have a solution!

                  and what OS?

                    diego thats the thing... its suppose to work.

                    and jus:
                    red hat linux 7.2 / ensim 3.1.3

                    yeah after the host put this on, I was re-uploading my stuff and I found it doing this.

                      Try changing error_reporting to E_ALL, and see if there are any errors....

                      Diego

                        Ok I turned that on and like I expected it just gives an error of Variable not defined... which is the whole problem.

                          well stupid me realized my mistake. I was including it with the url inside (just to make it easier cuz I have multiple calls to it in dif. subfolders) and thats the problem. Including a file on another server will get the output (thats why it would still show the html) but not the php.. the varialbes or functions.

                            Write a Reply...