Jump to content

Includes Issue / Fatal Error or Not Working


JasonHarper

Recommended Posts

Hello,

 

I'm having an issue that I just can't seem to figure out.  I have two include files - one that contains a function to return credentials for accessing the database and the other that generates/sends email.  The issue that I'm having is that if I can change all the include_once to include, I get a fatal error that the function can't be redeclared.  When I leave them as include_once, the first time the database credentials are needed, it works but subsequent calls to the function later in the code fail.

 

I feel like I'm missing something very simple but just can't figure it out for the life of me.  Thank you SO much for any help - I tried to illustrate my files/code below.

 

Thank you!

Jason

 

 

Filename:  access.php

Purpose:  Functions to provide database credentials to other functions/code

function getDatabaseDetails()
  {
      //CODE IS HERE
  }

 

Filename:  email.php

Purpose:  Functions to retrieve data from DB and send email

function sendEmail()
  {
      include_once '/includes/access.php'
      
      //CODE IS HERE
  }

 

Filename:  page.php

Purpose:  Actual content


include_once '/includes/access.php'
include_once '/includes/email.php'

//CODE IS HERE

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.