Jump to content


Photo

include file not working, IIS 6 Windows 2003


  • Please log in to reply
5 replies to this topic

#1 hc

hc
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 14 September 2006 - 08:33 PM

I have a file called test.php. When I browse to it, I get the results for the browser test

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6

But, the included file (testinc.php) does not get included. The contents of testinc.php are simply

<!-- a general PHP test -->
<?php phpinfo(); ?>

If I take that out and put it in the body of the test.php file, it works fine. So, it is clearly include files that are not working. Can someone please help. I have been searching all afternoon.

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<!-- testing sessions -->
<?php session_start(); ?>

<!-- testing browscap.ini -->
<?php
echo $_SERVER['HTTP_USER_AGENT'] . "<br/><br/>";
$browser = get_browser(null, true);
print_r($browser);
echo "<br/><br/>";
?>

<?phpinclude 'inctest.php';?>
</body>
</html>


#2 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 14 September 2006 - 09:32 PM

you haven't got a space between ?php and include
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 14 September 2006 - 09:38 PM

I see a few errors on here
1: <?php session_start(); ?> needs to be on line 1 of your script, before HTM headers are sent (doctype, <html>)

B: <?phpinclude should be <?php include('inctest.php'); ?> (missing space, brackets should not matter
This would HAVE to be in the same folder as the file you are running

A little tip
make ur php code like the following
<?php
include("bla_file");
?>
So <?php is on its own line
and
?> is on its own line
Tell me the problem, I will try tell you the solution

#4 hc

hc
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 14 September 2006 - 09:45 PM

ok, while that was true, and subsequently worked,  :-[

how about about this one. That small test started because of this...

I have this file, pretty simple

<?php
/*
* logon.php
* Created on Dec 14, 2005 10:51:13 AM
* by Keith Swallow
*
* Updated on 12/20/05 - 16:38:59
* by Matthew Miller
*
* Script to handle logons
*/

$includePath = '../classes/';  // Should be in a global config file as a constant
require_once($includePath . 'dataobject.inc');
require_once($includePath . 'employee.inc');
require_once($includePath . 'passmgr.inc');
require_once($includePath . 'functions.inc');

$bodyID = "logon";  // sets body ID for the view, helps with navigation.  Move into view?

if($_POST['submit'])  // if this form has been submitted
{
//unset($_POST['submitted']);  // reset the global variable in case they use other forms.
$username = $_POST['logonUsername'];
$uPass = $_POST['logonPass'];

$user = new Employee;
$id = $user->UsernameExists($username);  // Get employee ID
if($id === 0) // if does not exist
{
$pageTitle = "Logon Error: Username";
$error = "Username not found.";
include('../views/logonform.inc');
exit;
}
$user->SetEmployee($id);  // populate employee from DB

$pm = new PassMgr;
if(!$pm->Validate($uPass, $user->GetPass()))  // check passwords
{
$pageTitle = "Logon Error: Password";
$error = "Password incorrect.";
include('../views/logonform.inc');
exit;
}

// if everything worked out
session_start();
$_SESSION['username'] = $user->username;
$_SESSION['user_id'] = $user->id;
$_SESSION['loggedOn'] = TRUE;

$clients = $user->GetEmployers(array('Official'));

if(is_array($clients) && $_SESSION['user_id'] != 1)
{
$_SESSION['officialonly'] = 0;
}
else
{
$_SESSION['officialonly'] = 1;
}

header("Location: index.php");
}
else
{
session_start();
include('../views/logonform.inc');
}
?>

When I submit the page, instead of presenting me with a login message or error, it goes to blank page. nothing in the

if($_POST['submit'])

seems to get processed. Any ideas? Thanks

#5 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 14 September 2006 - 09:48 PM

Again, session_start(); HAS to be on line 1
This function sents HTM headers

2, Please post the FORM only
Tell me the problem, I will try tell you the solution

#6 hc

hc
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 14 September 2006 - 10:25 PM

ok, this is the form. The real kicker here is that this code works on a UNIX server. But when I bring it down to my develpment environment (Windows 2003), it does not work anymore. That is why I think it is a setting or something. Any help would be greatly appreciated. Thanks

<?php include('basicheader.inc'); ?>
<h1>Welcome to OPP</h1>
<form action="logon.php" method="post">
<p>Username: <input type="text" name="logonUsername" maxlength="30" value="<?php echo $_POST['logonUsername']; ?>" /></p>
<p>Password: <input type="password" name="logonPass" maxlength="30" value="" /></p>
<p><input type="submit" name="submit" value="Login" /></p>
</form>
<div id="notRegistered">
<h6>Not registered?</h6>
<p><a href="register.php">Sign up here</a>.</p>
</div>
<?php include('footer.inc') ?>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users