Include statement in php just displaying code.
Posted: Mon Aug 11, 2003 6:49 pm
Hi. I have searched so many forums and I am hoping someone here can help me. *begs*
Problem: I have a php script that is the beginnings of a guestbook form. The script is from mysql/php database applications book. In the script they have an include file to create database connections. Great idea! Only that is where my problems start. Instead of connecting I get the code displayed. I know the connection code works because I can place it directly into the script and it does connect.
Script:
<?php
include("dbconnect.php");
echo "Hi <BR>";
$var = Date("H");
if ($var<=11)
{
echo "good morning<BR>";
}
elseif ($var >11 and $var < 18 )
{
echo "good afternoon<BR>";
}
else
{
echo"good evening<BR>";
}
echo "connected";
echo "mysql is closed";
?>
DBconnect.php:
mysql_connect ("localhost", "webuser", "clippers") or die("Could not connect to database");
mysql_select_db ("guestbook") or die ("Could not select database");
Result:
mysql_connect ("localhost", "webuser", "clippers") or die("Could not connect to database"); mysql_select_db ("guestbook") or die ("Could not select database");Hi
good afternoon
connectedmysql is closed
So it just displays what is in dbconnect.php. Which is the source of my frustration.
PHP Configuration :
include_path ./ ./
Please, I would appreciate any ideas you may have. I am new to this, and don't really know anyone to ask for help. My setup is Windows 2000 machine, mysql, php 4.3.2, Apache 2.0.47. Thanks *hugs*
Problem: I have a php script that is the beginnings of a guestbook form. The script is from mysql/php database applications book. In the script they have an include file to create database connections. Great idea! Only that is where my problems start. Instead of connecting I get the code displayed. I know the connection code works because I can place it directly into the script and it does connect.
Script:
<?php
include("dbconnect.php");
echo "Hi <BR>";
$var = Date("H");
if ($var<=11)
{
echo "good morning<BR>";
}
elseif ($var >11 and $var < 18 )
{
echo "good afternoon<BR>";
}
else
{
echo"good evening<BR>";
}
echo "connected";
echo "mysql is closed";
?>
DBconnect.php:
mysql_connect ("localhost", "webuser", "clippers") or die("Could not connect to database");
mysql_select_db ("guestbook") or die ("Could not select database");
Result:
mysql_connect ("localhost", "webuser", "clippers") or die("Could not connect to database"); mysql_select_db ("guestbook") or die ("Could not select database");Hi
good afternoon
connectedmysql is closed
So it just displays what is in dbconnect.php. Which is the source of my frustration.
PHP Configuration :
include_path ./ ./
Please, I would appreciate any ideas you may have. I am new to this, and don't really know anyone to ask for help. My setup is Windows 2000 machine, mysql, php 4.3.2, Apache 2.0.47. Thanks *hugs*