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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:26:27+00:00 2026-06-18T04:26:27+00:00

after php code row 1 and 2, I got a notice and error message.

  • 0

after php code row 1 and 2, I got a notice and error message.

Notice: Undefined variable: dbc in …
Warning: mysqli_get_host_info()
expects parameter 1 to be mysqli, null given in …

connectdb();
echo mysqli_get_host_info($dbc);

Can you help me please to solve my notice & warning?

How can I make $dbc defined also for outher functions? I am working with error level -1 by the time being. please don’t tell not to display the notices as a solution. Unfortunately, I can’t understand the custom function variable passage issues. thanks.

function connectdb() 
{
    $dbc = mysqli_connect (db_host, db_user, db_password, db_name);
    if (!$dbc) 
        {
            $txt = mysqli_connect_errno().mysqli_connect_error();
            db_connect_error_mail($txt);
            unset ($txt);
            die('error message.');
        } 
    else 
        {
            return $dbc;
        }
}

  • 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-18T04:26:28+00:00Added an answer on June 18, 2026 at 4:26 am

    You aren’t assigning the return value of connectdb() method anywhere. You want:

    $connection = connectdb();
    echo mysqli_get_host_info($connection);
    

    For clarity I have used a different variable name as the one you use in your function, because they are different variables, as they are defined in different scopes.

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

Sidebar

Related Questions

Im trying to update the contents of an element after running some php code.
I have the following php code from php.net <?php // The i after the
I wanted to quick test a small snippet of PHP code. So, After doing
when passing parameters after index.php its showing 404 error .. its apache error not
Supposing I am inserting a row into a table in MySql by php code,
I got an XML file being echoed by PHP and all the code works
Possible Duplicate: include after PHP 404 header returning “Oops! This link appears to be
After using PHP for a while now, I've noticed that not all built-in PHP
After compiling PHP from source are the devel libraries still needed? For example, I
I am trying to receive a json object back from php after sending data

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.