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 6810581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:13:21+00:00 2026-05-26T20:13:21+00:00

My problem is, This is the file that is being included , <?php $dbhost

  • 0

My problem is,

This is the file that is being included ,

<?php
$dbhost = "localhost";
$dbuser = "****";
$dbpass = "***";
$dbname = "****";

$MYSQL_ERRNO = "";
$MYSQL_ERROR = "";

// Connect To Database
function db_connect() {
global $dbhost, $dbuser, $dbpass, $dbname;
global $MYSQL_ERRNO, $MYSQL_ERROR;

$link_id = mysql_connect($dbhost, $dbuser, $dbpass);

if(!$link_id) {
$MYSQL_ERRNO = 0;
$MYSQL_ERROR = "Connection failed to $dbhost.";
return 0;
}
else if(!mysql_select_db($dbname)) {
$MYSQL_ERRNO = mysql_errno();
$MYSQL_ERROR = mysql_error();
return 0;
}
else return $link_id;
}
?>

The main file has the following code to make db connection ,

<?php
require_once 'file.php';
$link_id = db_connect($dbname);
......
?>

But i got function undefined error.

Using Apache in Windows with PHP 5.3

  • 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-05-26T20:13:22+00:00Added an answer on May 26, 2026 at 8:13 pm

    1) Check relative paths for your includes.

    2) Just because the PHP documentation says you can use require_once without parenthesis doesn’t mean you should. Stay consistent, use require_once("file.php");.

    3) Be consistent with curly braces in your function. You’re missing one or two up there. I’d like to know if you rewrite your function the following way if it works:

    function db_connect() {
        global $dbhost, $dbuser, $dbpass, $dbname, $MYSQL_ERRNO, $MYSQL_ERROR;
        $link_id = mysql_connect($dbhost, $dbuser, $dbpass);
        if ($link_id === false) {
            $MYSQL_ERRNO = 0;
            $MYSQL_ERROR = "Connection failed to $dbhost.";
            return 0;
        } elseif (mysql_select_db($dbname) === false) {
            $MYSQL_ERRNO = mysql_errno();
            $MYSQL_ERROR = mysql_error();
            return 0;
        } else {
            return $link_id;
        }
    }
    

    And remember, checking your web server error logs usually helps.

    Edit:

    According to the comments for this answer, you’re not including the file you think you are. Use an absolute path for the include so you’re 100% sure of the file being included.

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

Sidebar

Related Questions

I have a first.js file included in the page index.php that have something like
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I become use raw socket and i have this problem: bad file descriptor the
Problem: I need to write/read objects from a file.This because I need to write/read
I've encountered this problem (while trying to add SQL Server Database (.mdf) file to
Here are the problem scripts: This is from the HTML file: <script type=text/javascript> var
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
Does anyone see a problem with this, its not working saying bad file descriptor
I was trying to code this problem in fortran. The output file contains the
I'm having a problem with getting this code to print out to file due

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.