Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:42:47+00:00 2026-06-03T20:42:47+00:00

I have 3 php files. The first (connexion.php) one contains a function I use

  • 0

I have 3 php files. The first (connexion.php) one contains a function I use to create a new PDO connexion:

<?php
header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('Europe/Paris');

function connexion($host, $user, $pass, $db){
    $db_host = $host;  
    $db_user = $user;  
    $db_password = $pass;  
    $db_database = $db;               
    return $connexion = new PDO("mysql:host=$db_host;dbname=$db_database;charset=utf8", $db_user, $db_password);
}

?>

The second file (my_function.php) contains a function that contains only one function that connects to a db and then is echoing some information.

    <?php
    include(connexion.php);
    function my_first_function(){
        try{
           $connexion = connexion('localhost', 'user', 'user', 'mydb');
           $connexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
           //some code that echoes information
        }
        catch(...){...}
    }
    ?>

My problem is when I try to include that last file into my third php script in order to be abble to use the function. The script is not even launching. I just have ‘internal error’. If I remove the include(my_function.php) my file is loaded properly. I don’t get it. Hope someone can help me understand. Thanks in advance. Cheers. Marc. Here below the third file:

<?php
include('connexion.php');
include('my_function.php');

//some code
my_first_function();
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:42:48+00:00Added an answer on June 3, 2026 at 8:42 pm

    You should not use include('connexion.php'); in the third file as it will also be included already automatically when you do include('my_function.php');

    As it contains a function declaration, that will lead to an error because that function has already been declared.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 files 1) show_createtable.html 2) do_showfielddef.php 3) do_showtble.php 1) First file is
I have several PHP files include()ing other files from several other directories. In one
I have two files in use. The first is a front end select box
First I have a PHP file that gets data and file from a HTML
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have some php files in a server which generate xml code in them.
I have various PHP files which data is Posted to (like the password when
I have 2 php files. I am unable to get B's global variable from
I have 50 php files that I would like to run simultaneously from the
I have a PHP script that creates other PHP files based on user input.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.