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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:12:26+00:00 2026-06-17T10:12:26+00:00

I am trying to make a simple SELECT query to my database with a

  • 0

I am trying to make a simple SELECT query to my database with a MySQLi prepared statement. I have read numerous tutorials and followed them very closely but for some reason it is still not working. Below is the query code:

<?php
$user = 'abc';
$dbconn = new mysqli("localhost", "my_user", "my_password", "my_table");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
if ($stmt = $dbconn->prepare("SELECT id, pass  FROM my_table WHERE user=?")) {
$stmt->bind_param("s",$user);    
$stmt->execute();
$stmt->bind_result($db_id,$db_pass);
$stmt->fetch();
$stmt->close();
}
$dbconn->close();
echo $db_id . ' ' . $db_pass;
?>

When I run this is does not say I have a connection error but a server error. I have a decent amount of PHP experience but am completely new to MySQLi prepared statements. Any help would be greatly appreciated; thank you for your time.

  • 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-17T10:12:27+00:00Added an answer on June 17, 2026 at 10:12 am

    For someone who have a decent amount of PHP experience you are quite light-minded about error reporting.
    As you didn’t provide an error message, we can only guess that it is regular web-server’s 503 response.
    In this case you have to search server’s error_log for the actual error message, read it, and take appropriate actions to fix it.

    Checking $dbconn->error also helps.

    There are 2 way of reporting errors:

    • displaying them on-screen (decent at development but unacceptable on production)
    • writing them in log (an absolute must on a production server)

    there are some ini settings responsible for this behavior.

    • display_errors tells PHP wheither it should display errors or not
    • log_errors tells PHP wheither it should log errors or not. by default it logs into web-servers’ error_log
    • error_log tells php the filename where PHP errors have to be written

    please set appropriate settings using your hosting tools.
    Otherwise you’d be unable to use this host anyway – a programmer just can’t work if he cant’s see error messages.

    Once you get your hands on the error message, it is extremely useful to forward it directly into google search form. Most likely someone already encountered the same and even asked it on Stackoverflow

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

Sidebar

Related Questions

I am trying to make simple mysql select query, I have 3 tables post:
We're currently stuck trying to make a simple (?) SQL query. We have these
I am trying to make a simple query that will update a user database
Trying to make simple minesweeper game in python, but have one problem. I have
im trying to make a simple search on my database from the index action
I have a very simple Groovy class where I'm just trying to select a
I am trying to make a simple query to a small MYSQL table, but
I am trying to make a simple load more button where I have an
Hey, I am trying to make an if statement that redirects them to a
I am trying to make a query with Hibernate criteria API. It looks simple

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.