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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:08:54+00:00 2026-06-04T21:08:54+00:00

I was told to stop using MySQL and now learning MySQLi. However I ran

  • 0

I was told to stop using MySQL and now learning MySQLi. However I ran into a problem using fetch array and don’t know what I did wrong.

//Connect to db
include "mysqli_connect.php";

// Construct our join query
$sql = "SELECT userID, username, lastlogin FROM users";

//Crate results
$result = mysqli_query($link, $sql);

// Print out the contents of each row into a table 
$row = mysqli_fetch_array($result, MYSQLI_BOTH);

// Free result set
mysqli_free_result($result);

// Close connection
mysqli_close($link);

Messages I see:

  • [Connection Successful] Host info: db413417616.db.1and1.com via
    TCP/IP
  • Warning: mysqli_query() [function.mysqli-query]: Couldn’t fetch
    mysqli in /homepages/9/d413002686/htdocs/maintenance/testsession.php
    on line 9
  • Warning: mysqli_fetch_array() expects parameter 1 to be
    mysqli_result, null given in
    /homepages/9/d413002686/htdocs/maintenance/testsession.php on line 12
  • Warning: mysqli_free_result() expects parameter 1 to be
    mysqli_result, null given in
    /homepages/9/d413002686/htdocs/maintenance/testsession.php on line 15
  • Warning: mysqli_close() [function.mysqli-close]: Couldn’t fetch
    mysqli in /homepages/9/d413002686/htdocs/maintenance/testsession.php
    on line 18 ()

I used this to for mysqli_connect.php: http://www.php.net/manual/en/mysqli.construct.php

<?php
// $link (host, username, password, database)
$link = mysqli_connect('host', 'username', 'password', 'database');

//If connection is successful, otherwise show error message. 
if (!$link) {
    die('[Connect Fail] Error: (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}
// Echo success message
echo '[Connection Successful] Host info: ' . mysqli_get_host_info($link) . "\n";

// Close the link
mysqli_close($link);
?>
  • 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-04T21:08:55+00:00Added an answer on June 4, 2026 at 9:08 pm

    This line in your include file should be removed:

    // Close the link
    mysqli_close($link);
    

    You’re closing $link, a.k.a. your connection to the database, and then trying to use it in your query. You only want to close it when you’re all done with it.

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

Sidebar

Related Questions

I was told that using break and continue labels in an OOP language is
A consultant told me recently that he has clients using IIS. Those servers accept
I ran an sql via the mysql command prompt, but it was taking too
I was told that if using SqlCommand in C# and if you were to
Someone told me, after using console.log() method, I would not need alert boxes and
I'm having a problem with MySQL going to sleep because a PHP script takes
Someone told me that openGL is for graphic only, and that it's very bad
Someone told me to do this in order to keep track of latest people
Someone told me once there was a good novel around the story of the
I was told by an experienced programmer(spoj,codechef,topcoder etc ) than as a general rule

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.