Page 1 of 1

Php echos whole included file.

Posted: Sat Jan 23, 2010 1:15 pm
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.

Re: Php echos whole included file.

Posted: Sat Jan 23, 2010 1:18 pm
by greyhoundcode
Would be appreciated if you could post some code? Might provide a fuller understanding of the particular problem you are facing.

Re: Php echos whole included file.

Posted: Sat Jan 23, 2010 1:40 pm
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.