Php echos whole included file.

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
jewelthief
Forum Newbie
Posts: 13
Joined: Sat Aug 29, 2009 1:46 am

Php echos whole included file.

Post by jewelthief »

I am very new to php. I have written my functions in separate file and included that file in my main .php file. Now when I get responseText ( I am working with Ajax) whole of the included file gets echoed i.e. code. why is this behavior of php and how should i make sure that php only echos what i tell it to.

Any help would be appriciated.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Php echos whole included file.

Post by greyhoundcode »

Would be appreciated if you could post some code? Might provide a fuller understanding of the particular problem you are facing.
jewelthief
Forum Newbie
Posts: 13
Joined: Sat Aug 29, 2009 1:46 am

Re: Php echos whole included file.

Post by jewelthief »

functions.php file

Code: Select all

 
 
function UdateAtServer($xmlDoc,$i)
    {
          $num_of_subTasks = $xmlDoc->getElementsByTagName("abc")->item($i).length;
            
            
    }
main.php file

Code: Select all

require_once("functions.php");
        if($num_of_tasks > 0)
        {
            $con = mysql_connect("localhost:3306","root","");
            if($con)
            {
               if( mysql_select_db("fgh",$con))
               {
                    for($i =0;$i <$num_of_tasks;$i++)
                    {
                        if($xmlDoc->getElementsByTagName("abc")->item($i)->hasAttribute("new"))
                        {
                            UdateAtServer($xmlDoc,$i);
                            
                        }   
                        
                    }
               } 
            }
 
It is a chuck of code. When i make alert()of responseText in javascript, I get whole of the functions.php file as responseText.
Post Reply