Skip to main content
code formatting
Source Link
Robbert
  • 6.6k
  • 6
  • 38
  • 64

I have a database, db_db which I want to display data from in my browser. I have put this php code (display.php) under /var/www/ and trying to access localhost/display.php. Though everytime I come across "Server Error" The website encountered an error while retrieving http://localhost/display.php. It may be down for maintenance or configured incorrectly.

The code is below:

<?php
 
 //make conn
 $link = mysql_connect('localhost', 'root', '');

 //select db
 
 mysql_select_db('db_db') or die( "Unable to select db");
 
 $sql =  "SELECT * FROM results WHERE jobid = 'abc'";
 
 $records = mysql_query($sql);
 
 ?>


<html>
 
<head>
 <title> Result Info </title>
</head>

<body>
 
<table width="600" border = "1" cellpadding = "1" cellspacing= "1">
<tr>
 
 <th>id</th>
 <th>name</th>
 
 <tr>

<?php
 while($result = mysql_fetch_assoc($records)){
 
    echo "<tr>";
    echo "<td>.$result['id'].</td>";
    echo "<td>.$result['name'].</td>";
 
    echo "</tr>";
 }//end while

 
?>

</table>
</body>
</html>

Not sure where am I going wrong.

I have a database, db_db which I want to display data from in my browser. I have put this php code (display.php) under /var/www/ and trying to access localhost/display.php. Though everytime I come across "Server Error" The website encountered an error while retrieving http://localhost/display.php. It may be down for maintenance or configured incorrectly.

The code is below:

<?php
 
 //make conn
$link = mysql_connect('localhost', 'root', '');

//select db
 
mysql_select_db('db_db') or die( "Unable to select db");
 
$sql =  "SELECT * FROM results WHERE jobid = 'abc'";
 
$records = mysql_query($sql);
 
 ?>


<html>
 
<head>
 <title> Result Info </title>
</head>

<body>
 
<table width="600" border = "1" cellpadding = "1" cellspacing= "1">
<tr>
 
 <th>id</th>
 <th>name</th>
 
 <tr>

<?php
 while($result = mysql_fetch_assoc($records)){
 
    echo "<tr>";
    echo "<td>.$result['id'].</td>";
    echo "<td>.$result['name'].</td>";
 
    echo "</tr>";
 }//end while

 
?>

</table>
</body>
</html>

Not sure where am I going wrong.

I have a database, db_db which I want to display data from in my browser. I have put this php code (display.php) under /var/www/ and trying to access localhost/display.php. Though everytime I come across "Server Error" The website encountered an error while retrieving http://localhost/display.php. It may be down for maintenance or configured incorrectly.

The code is below:

<?php
 //make conn
 $link = mysql_connect('localhost', 'root', '');

 //select db
 mysql_select_db('db_db') or die( "Unable to select db");
 $sql =  "SELECT * FROM results WHERE jobid = 'abc'";
 $records = mysql_query($sql);
?>


<html>
<head>
 <title> Result Info </title>
</head>

<body>
<table width="600" border = "1" cellpadding = "1" cellspacing= "1">
<tr>
 <th>id</th>
 <th>name</th>
<tr>

<?php
 while($result = mysql_fetch_assoc($records)){
   echo "<tr>";
   echo "<td>.$result['id'].</td>";
   echo "<td>.$result['name'].</td>";
   echo "</tr>";
 }//end while
?>

</table>
</body>
</html>

Not sure where am I going wrong.

Source Link
Quick Silver
  • 433
  • 2
  • 8
  • 17

Server error while trying to display data from mysql db in php

I have a database, db_db which I want to display data from in my browser. I have put this php code (display.php) under /var/www/ and trying to access localhost/display.php. Though everytime I come across "Server Error" The website encountered an error while retrieving http://localhost/display.php. It may be down for maintenance or configured incorrectly.

The code is below:

<?php

 //make conn
$link = mysql_connect('localhost', 'root', '');

//select db

mysql_select_db('db_db') or die( "Unable to select db");

$sql =  "SELECT * FROM results WHERE jobid = 'abc'";

$records = mysql_query($sql);

 ?>


<html>

<head>
 <title> Result Info </title>
</head>

<body>

<table width="600" border = "1" cellpadding = "1" cellspacing= "1">
<tr>

 <th>id</th>
 <th>name</th>

 <tr>

<?php
 while($result = mysql_fetch_assoc($records)){

    echo "<tr>";
    echo "<td>.$result['id'].</td>";
    echo "<td>.$result['name'].</td>";

    echo "</tr>";
 }//end while


?>

</table>
</body>
</html>

Not sure where am I going wrong.