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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:37:09+00:00 2026-05-24T03:37:09+00:00

i literally just started looking into php, connecting to a remote database and returning

  • 0

i literally just started looking into php, connecting to a remote database and returning data. I have been following a tutorial however when i apply the same code (as on the tutorial), i get

Server error

The website encountered an error while retrieving http://localhost:8888/file.php. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this web page later.

This is the script – the database connection is fine, i believe its the retrieval of data that causes the error but have no idea on how to fix it ..

  <?php

   // Database credentials
   $host = "localhost"; 
   $db = "json"; 
   $uid = "json"; 
   $pwd = "json1";

    // Connect to the database server   
    $link = mysql_connect($host, $uid, $pwd) or die("Could not connect");

   //select the json database
   mysql_select_db($db) or die("Could not select database");


// Create an array to hold our results
   $arr = array();
   //Execute the query
   $rs = mysql_query("SELECT id,userid,firstname,lastname,email FROM users");

   // Add the rows to the array 
   while($obj = mysql_fetch_object($rs)) {
   $arr[] = $obj;

?>
  • 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-24T03:37:10+00:00Added an answer on May 24, 2026 at 3:37 am

    At the end of your script, you have this :

    // Add the rows to the array 
       while($obj = mysql_fetch_object($rs)) {
       $arr[] = $obj;
    
    ?>
    

    You are opening { on the while line ; but never closing it.

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

Sidebar

Related Questions

Started looking at the win32 API on this site: http://www.winprog.org/tutorial/start.html I've literally just compiled
I've literally just started using the Unity Application Blocks Dependency Injection library from Microsoft,
I am just getting started using any DI/IoC toolset and have a very basic
I'm just getting started developing for Android and I'm running into a weird problem.
...and I mean LITERALLY just beginning. As in, I just started earlier today. All
We're using EF Code first, and have a data context for our sales database.
The following code recently started returning empty strings. It works on other systems, so
IIS is literally sending <?php ... ?> code to the browser rather then executing
If you have binary strings (literally String objects that contain only 1's and 0's),
I've been trying to track this one for literally a month now without any

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.