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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:16:10+00:00 2026-05-23T20:16:10+00:00

The following query is not executing and I am stumped as to why. The

  • 0

The following query is not executing and I am stumped as to why. The query is returning my die clause of ‘error querying database’ yet all of my info is exact.

Have I got a syntax error in my query variable?

<?php
$db_host     = 'localhost';
$db_user     = 'root';
$db_pass     = 'root';
$db_database = 'bbg_db_2'; 

$dbc = mysql_connect($db_host,$db_user,$db_pass) or die('Unable to establish a database connection');

$query = "SELECT category_name, category_desc FROM categories";
$result = mysqli_query($dbc, $query) or die ('error querying database');

while ($row = mysqli_fetch_array($result)) {

    $catname = $row['category_name'];
    $catdesc = $row['category_desc'];

    echo "<li>$catname</br><span>$catdesc</span></li>";
}

mysqli_close($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-05-23T20:16:11+00:00Added an answer on May 23, 2026 at 8:16 pm

    Two problems:

    • You connected with the mysql API, but then tried to query with the mysqli API;
    • You never selected the database with mysqli_select_db.

    Performing some basic error checking with mysqli_error($dbc) would have revealed this to you pretty quickly.


    Also, as a style note, ARGH tabs inside lines! Bad! Wrong! Tabs are for indentation, not alignment.

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

Sidebar

Related Questions

I have the following LINQ expression that's not returning the appropriate response var query
I am getting the following error while executing the following query in an Stored
I'm getting an error while executing following select query: ResultSet rs = St.executeQuery(select *
This has to be obtained from a remote machine. The following query works not
The following query returns values for months with sales but not for months where
Why Nibernate HQL can not handle the following query: from Deal D where (D.ApprovalDate
I have the following query: var req= (from tl in resultlist where (tl.Message.StartsWith(Do not
I am running following query in SQL*Plus CREATE TABLE tbl_audit_trail ( id NUMBER(11) NOT
I am trying to run the following query, but I am not sure if
Order by descending is not working on LINQ to Entity In the following Query

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.