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

  • Home
  • SEARCH
  • 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 8915295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:56:37+00:00 2026-06-15T04:56:37+00:00

I have an assignment for school: I need to make a user database. First

  • 0

I have an assignment for school: I need to make a user database.

First I need to know how to get information from tables in my database.
Then I need to write usernames to the database.

Let’s start with the first one:

I am working with MAMP.
I got this sample from my teacher, I added some echos in there.

< ?php

$dbhost  = 'localhost';    // Unlikely to require changing
$dbname  = 'chrisdb';        // Modify these...
$dbuser  = 'root';        // ...variables according
$dbpass  = 'root';        // ...to your installation

$db_server=mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
echo("1");
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
echo("2");
mysql_select_db($dbname)
    or die("Unable to select database: " . mysql_error());
echo("3");

?>

All the echos gets printed. Does that mean I have access to the server?
How do I access a table in the db and get the value of it?

And how do I write to the database?

I am not in search for the best possible code, more like the simplest possible code.
I appreciate all help you can give me. If you do help, will you please explain what your code means?

  • 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-15T04:56:38+00:00Added an answer on June 15, 2026 at 4:56 am

    You write to the database by sending an INSERT statement and read using a SELECT statement. See the documentation

    I personally hate W3Schools, but this article will get you started on how to insert data into a database.

    You should note that mysql_ functions are being deprecated and you should use mysqli_ or PDO instead.

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

Sidebar

Related Questions

Hello is have a question for a school assignment i need to : Read
As a school assignment, I need to find a way to get the L1
I need to implement a chess game for a school assignment, and you have
I have an assignment from school where the program is supposed to close when
I have an assignment at school to build a webserver that handles GET/HEAD/PUT requests,
I have a school assignment where I need to create a data-driven style of
For a school assignment, we have to make a Usecase diagram. But the documentation
I need to write a C program (for a school assignment to determine cache
I have an assignment for school to make a program which results in either
For a school assignment we have to make a client server chat program in

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.