473,800 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP5 Include Doesn't Work?

LacrosseB0ss
113 New Member
I'm currently working on an online directory system using PHP (due to server constraints). Normally I would use something else but c'est la vie! I have my pages on the server (Login.php, SomethingElse.p hp, etc.php). All of them have some form of php code associated with them.
In my cgi-bin folder, I have the code which references my data files (XML for now, may switch to MySQL later). I am getting errors that say
"cannot open file: ../cgi-bin/path.xml" and something about include.

Now, I did some research and it claims that with php5, the code cannot use an include line for a file in a different directory. My question(s) are:
1. Is this true?
2. If so, is there another place I can put my files so the user can't see them? (code and data)

Thanks all. I've just started working with php for this project so I really don't have a clue. Also, it's my first server project so the cgi-bin stuff was from stuff I've seen online. Thanks in advance for the help.

- LB
Nov 14 '07 #1
16 9052
ak1dnar
1,584 Recognized Expert Top Contributor
a XML file? why do you want to include this in your php file. can I see specific coding that you have used so far, please !
Nov 14 '07 #2
LacrosseB0ss
113 New Member
The reason for the XML was because I was originally going to code it as a servlet modifying an example from a college class. So I made up the XML files and then found out servlets won't work on our server.

Having said that, here's the code:
[php]
<?php session_start;
//include("../cgi-bin/PHP/dirlogin.php");
//include("../other/dirlogin.php");

$_SESSION['usedID']="Not Found";

function login()
{
$blnFound = false; //was user found? default NO

//open master XML
$members=simple xml_load_file(' ../cgi-bin/XML/CongregationMas ter.xml');

//search for user
foreach($member s as $user)
{
//if found, store ID as session
if ($user->FirstName == $_POST['txtFName'] && $user->LastName == $_POST['txtLName'] && $user->PostalCode == $_POST['txtPwd'])
{
$_SESSION['userID']=$user->ID;
echo $_SESSION['userID']; //testing line
$blnFound=true;
break; //break out of the loop b/c user was found.
}
}

if ($_SESSION['userID'] == "Not Found")
{
echo "User Not Found!"; //testing line
$blnFound=false ;
}

return true; //testing - should be $blnFound
} //*************** *************** *************** ****
//END OF INCLUDE

function checkLogin()
{
if(isset($_POST['cmdLogin']))
{
$found = login();

if ($found)
{
header("Locatio n: DirConfirmTEST. php");
exit();
}
else
{
echo "USER NOT FOUND!";
}
}
}

if(isset($_POST['cmdLogin']))
{
checkLogin();
}
?>
[/php]

The commented stuff was in my original file. When it wasn't working I thought it was the cgi-bin folder so I moved it. Then I read php5 may not use includes. So I put it all together. Anyway, now the "simplexml_file _load()" line doesn't work. Any help is greatly appreciated. Thanks!

- LB
Nov 14 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, LB.

What error message are you getting?
Nov 15 '07 #4
LacrosseB0ss
113 New Member
I am getting 2 consistently. I tried a few other things before replying back but they did no good. The error messages are:
Warning: include(../PHP/dirlogin.php) [function.includ e]: failed to open stream: No such file or directory in /home/poqumtu/public_html/bloorcentral/DirLogin.php on line 35

Warning: include() [function.includ e]: Failed opening '../PHP/dirlogin.php' for inclusion (include_path=' .:/usr/lib/php:/usr/local/lib/php') in /home/poqumtu/public_html/bloorcentral/DirLogin.php on line 35
I also got an e-mail from our server owner/operator. According to him, php5 is installed. However, he did not know about HTTP includes (is this the entire path?) or why I was getting the include() error as he hasn't worked much with php.

I have tried removing the php file from the cgi-bin folder, where it was originally, thinking that was the problem. Guess not. Any assistance anyone can provide would be greatly appreciated. This is really beginning to urk me....

Thanks!
- LB

PS: that was my 100th post. Go Me! Can we have a party?
Nov 15 '07 #5
LacrosseB0ss
113 New Member
as an aside, does anyone know of any good, free php debuggers out there? Right now I'm doing my HTML in Dreamweaver and I'm coding my php stuff in EditPlus. I'm not overly found of having to upload to the server whenever I want to test my code. Thanks for this as well!
Nov 15 '07 #6
pbmods
5,821 Recognized Expert Expert
Heya, LB.

Try seeing if you can include /home/poqumtu/public_html/PHP/dirlogin.php.

In terms of a 'good PHP debugger'...

Try PHP :)

Install PHP and Apache on your development machine so you can test your scripts before you upload them.

Just be careful... you might have the latest version of PHP installed on your development machine, but if the server you're uploading to is running an earlier version (almost a complete certainty), you'll have to do some additional testing anyway to make sure your code is compatible with the older version.
Nov 15 '07 #7
LacrosseB0ss
113 New Member
I fixed the include late last night. I took out the ../ before the cgi-bin and it works now. The problem I am having now is in the included file, my session variables are not working. I'm baffled by it honestly. I originally had the "session_start( );" line however it produced the following 2 errors:
Warning: session_start() [function.sessio n-start]: Cannot send session cookie - headers already sent by (output started at /home/poqumtu/public_html/bloorcentral/DirLogin.php:8) in /home/poqumtu/public_html/bloorcentral/cgi-bin/PHP/dirlogin.php on line 2

Warning: session_start() [function.sessio n-start]: Cannot send session cache limiter - headers already sent (output started at /home/poqumtu/public_html/bloorcentral/DirLogin.php:8) in /home/poqumtu/public_html/bloorcentral/cgi-bin/PHP/dirlogin.php on line 2
Removing the session_start() ; line removed the errors but in both situations the $_SESSION['userID'] resulted in an empty variable. I'm so lost ....

As for the "PHP" as a debugger???? Can you provide more info. I have PHP 5 on my system as well as Apache Tomcat. I can't figure out how I'm supposed to run my scripts off my machine first ... Thanks for the help so far.

- LB
Nov 15 '07 #8
jx2
228 New Member
The problem I am having now is in the included file, my session variables are not working. I'm baffled by it honestly. I originally had the "session_start( );" line however it produced the following 2 errors:
you have to use session_start() as a very first thing you do
i mean :
[php]
<?php
//make sure that before<?php there is NOTHING no empty lines,
//no html, no any white spaces
session_star();
//the rest of yor code...
[/php]

regards
jx2
Nov 15 '07 #9
pbmods
5,821 Recognized Expert Expert
Heya, LB.

Sounds like that particular file is getting included twice.

Consider using include_once instead of include.

This also works:
Expand|Select|Wrap|Line Numbers
  1. if( ! session_id() )
  2. {
  3.     session_start();
  4. }
  5.  
Nov 16 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
19120
by: gf | last post by:
I had a client recently contact me with a script that wasn't working. I quickly isolated the problem as to the fact that the $_GET array was not being made available to all scripts, even though register_globals was set to ON. The client then notified his host who seemed to know exactly the issue and we added these lines to the top of the script (this script is included in all other scripts) and it solved the problems: /* mp.net patch...
4
2805
by: Mxsmanic | last post by:
The require() I'm using in a PHP script has stopped working after I moved from PHP4 and Apache 1.3.x to PHP5 and Apache 2.x. Now I get messages like this: Warning: main(/includes/ReloadScript.html) : failed to open stream: No such file or directory in /usr/local/www/htdocs/main/AOLCompression.php on line 14 Fatal error: main() : Failed opening required '/includes/ReloadScript.html' (include_path='.:/usr/local/lib/php') in
2
2054
by: Paul Charlton-Thomson | last post by:
I'm really struggling here ... my site works on the basis of <A HREF="index.php?folder=x&page=y" In PHP 4 index.php had the line ... include $folder . "/" . $y . ".php"; Which was fine but doesn't work in PHP5. I have tried to correct it as per the documentation but am struggling ... can someone help me?
2
2587
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different users, I use suexec and a wrapper script for php files. to make it a bit clearer, i'll post the different snippets: httpd.conf:
3
3462
by: abeb | last post by:
Hi all, I recently given a task to upgrade a running server (PostgreSQL7.3+Apache2.0+PHP4.2) to a new server with PostgreSQL8.1+Apache2.2+PHP5.1 installed (all Fedora Core 6 packages). All is running well, except the old php scripts. Plz bare with me I'm not a programmer, I've spent a month researching the PHP manual, the net, other forum and still can't exactly point out the porblem. I have set register_globals on and...
19
2371
by: McKirahan | last post by:
I am working in two environments neither configuration of which I can change; one's my Web host the other a client. My Web host requires the use of the ".php5" extension to use PHP v5.1.4; where ".php" is used for PHP v4.3.11. My client supports PHP v5.2.0 with the ".php" extension. Is there a way to reliably determine if the ".php5" extension must be used on a server? Perhaps via a "phpinfo()" value?
8
1602
by: Tony B | last post by:
Hi, I'm trying out my local copy of a site that uses php4, mysql,apache2. I've moved it from a php4 machine to a php5 machine, and it doesn't work at all now. A couple of other php4 sites I've moved, which are straight php and do not use mysql are working fine though. So it seems that the mysql php interface maybe the problem. Are there any site/docs which cover the differences between php4 and php5, and likely problems that may occur,...
0
1407
by: Erwin Moller | last post by:
Hi group, I found something strange in PHP5.2.4 (on IIS7/Vista). I am working on an app that has been running just fine under heavy load for over a year at some custumer of mine. (they have PHP5.1 on W2003 Server, ISAPI) I imported the whole project locally on a slightly more modern version of PHP 5.2.4 to make a few adjustments.
3
1642
by: Tom | last post by:
Hi all i have problem with include function in my code after change php4 to php5. after standard html code i put in html body <? include ("filename.php"); ?> and close body and html. With php4 i got pictures from php file but now in php5 i got blank page. any suggestion? tnx
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.