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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:20:50+00:00 2026-06-15T17:20:50+00:00

I’ve got a pretty standard call to a MySQL database and for some reason

  • 0

I’ve got a pretty standard call to a MySQL database and for some reason I can’t get the code to work. Here’s what I have:

$mysqli = mysqli_connect("localhost","username","password");
if (!$mysqli)
  {
  die('Could not connect: ' . mysqli_error($mysqli));
  }
session_start();
$sql = "SELECT * FROM jobs ORDER BY id DESC";
$result = $mysqli->query($sql);
$num_rows = mysqli_num_rows($result);

Now, first, I know that it is connecting properly because I’m not getting the die method plus I added an else conditional in there previously and it checked out. Then the page displays but I get the errors:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in blablabla/index.php on line 11

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in blablabla/index.php on line 12

I’ve double-checked my database and there is a table called jobs with a row of “id” (it’s the primary row). The thing that confuses me is this is code that I literally copied and pasted from another site I built and for some reason the code doesn’t work on this one (I obviously copy and pasted it and then just changed the table name and rows accordingly).

I saw the error and tried:

$num_rows = $mysqli_result->num_rows;
$row_array = $mysqli_result->fetch_array;

and that fixed the errors but resulted in no data being passed (because obviously $mysqli_result has no value). I don’t know why the error is calling for that (is it a difference in version of MySQL or PHP from the other site)?

Can someone help me track down the problem? Thanks so much. Sorry if it’s something super simple that I’m overlooking, I’ve been at it for a while.

  • 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-15T17:20:51+00:00Added an answer on June 15, 2026 at 5:20 pm

    You didn’t selected the database

    $mysqli = mysqli_connect("localhost","username","password","database");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.