Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with INCLUDE statement

Status
Not open for further replies.

JMay0816

Programmer
Mar 1, 2007
34
0
0
US
I'm having an issue using INCLUDE.

On the first page, I have the following code:

<?php
require_once('config.php');

session_start();
$uid=$_SESSION['uid']; // UserID variable
$tdate=$_SESSION['tdate']; // Current Date variable
$tdate1=$_SESSION['tdate1'];

$connect=mysql_connect($host, $user1, $pw) or die ("Unable to Connect to Database!");
$dbselect=mysql_select_db($db) or die ("Database does not exist!");

include 'gensysmess.php';

...



On the gensysmess.php page, I have the following code:

<?php
$a1query="INSERT into umessages (fromuser, umessage) values ('SYSTEM', 'First Notice') ";
$a1result=mysql_query($a1query) or die ("Error in Query".mysql_error());
?>

It doesn't work.

If I put the code from gensysmess.php in place of the INCLUDE statement...it works.

If I copy the code above the INCLUDE statement to the gensysmess.php page.....it doesn't work.

I'm at a loss. Can someone help?

thx
 
what does "it doesn't work" mean? what error messages are you getting?
 
no error messages...however the INSERT query on the second page does not insert the record from the INCLUDE statement.

If I move the query code to the first page in place of the INCLUDE, the record gets inserted.

Therefore, by not working, I mean the code is not executing via the INLCUDE statement.
 
are you showing us the entire code? there is no reason that i can see why the insert should neither work nor throw and error message.
 
only the code up to the INCLUDE statement is shown...which is actually the very first few lines on the page.

As for the gensysmess.php page....yes...that is the only code on that page (for now). Just the two lines.
 
then it's most likely that the include is not happening. perhaps the file is not in the same directory or the include path, or the php process does not have read access to the file.

try debugging by adding this to the beginning of the main script
Code:
error_reporting(E_ALL);
and changing the include to a require.
 
bingo....somehow the file was not saved in the correct location. thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top