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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.