<html>
<head>
</head>
<body>

<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");

mysql_select_db("ong_assesment',$connect);
$query = mysql_query (SELECT Agent_ID,Address/Suburb,Bedrooms/Bathrooms,Price FROM suburbs);

{
echo '<tr>';
echo '<td>'. $row[Agent_ID].'</td>';
echo '<td>'. $row[Address].'</td>';
echo '<td>'. $row[Bedrooms].'</td>';
echo '<td>'. $row[Price].'</td>';

echo '</table>'
mysql_close();
}
?php>
</body>
</html>
Member Avatar
diafol

change to

echo '</table>';

Try this, bit different to your script.. Have a look at yours, you have many errors:

<html>
<head>
</head>
<body>

<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");

mysql_select_db("ong_assesment",$connect);
$query = "SELECT Agent_ID,Address/Suburb,Bedrooms/Bathrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result))
{
    echo '<tr>';
    echo '<td>'. $row[Agent_ID].'</td>';
    echo '<td>'. $row[Address].'</td>';
    echo '<td>'. $row[Bedrooms].'</td>';
    echo '<td>'. $row[Price].'</td>';
}
    echo '</table>';

?>
</body>
</html>

e.g. in yours you have:

mysql_select_db("ong_assesment',$connect);

should be:

mysql_select_db("ong_assesment",$connect);

Hope this helps

yes it work but the database not showing

Member Avatar
diafol

WHat editor / IDE are you using? Some editors can spot these errors for you, highlighting the problem lines.

Is there an error showing? Is there anything in the table?

it came out table but no data.
message:No database selected

I don't think you're understanding me.. I asked is there an error message showing, NOT what text editor you're using... Ok, try this:

<html>
<head>
</head>
<body>

<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");

mysql_select_db("ong_assesment",$connect);
$query = "SELECT Agent_ID,Address/Suburb,Bedrooms/Bathrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_erro());

if(!mysql_affected_rows() >= 1)
{
    echo 'There are no entries inside the database';
}
while($row = mysql_fetch_array($result))
{
    echo '<tr>';
    echo '<td>'. $row[Agent_ID].'</td>';
    echo '<td>'. $row[Address].'</td>';
    echo '<td>'. $row[Bedrooms].'</td>';
    echo '<td>'. $row[Price].'</td>';
}
    echo '</table>';

?>
</body>
</html>

Do you get the output: There are no entries inside the database? OR do you get something else?

Is there a database called "ong_assesment"

Ok, try this:

where you have:

mysql_select_db("ong_assesment",$connect);

change it to:

$db_selected = mysql_select_db("ong_assesment", $connect);

Making sure, your database name is called "ong_assesment".

Parse error: syntax error, unexpected T_VARIABLE in F:\xampp\htdocs\movies4.php on line 14

Now you have to insert data, for the data to be shown :) Do you use mysqladmin? If so, you can just throw some example data in just to test!

Please post your script, how it looks now.. Removing any passwords etc..

<head>
</head>
<body>
<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect)
$query = "SELECT Agent_ID,Address,Bedrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_error());
if(!mysql_affected_rows() >= 1)
{
echo 'There are no entries inside the database';
}
while($row = mysql_fetch_array($result))
{
 echo 'There are no entries inside the database';
}
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>'. $row[Agent_ID].'</td>';
echo '<td>'. $row[Address].'</td>';
echo '<td>'. $row[Bedrooms].'</td>';
echo '<td>'. $row[Price].'</td>';
}
echo '</table>';
?>
</body>
</html>

LOOK at the syntax..

<head>
</head>
<body>
<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect);
$query = "SELECT Agent_ID,Address,Bedrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_error());
if(!mysql_affected_rows() >= 1)
{
echo 'There are no entries inside the database';
}

while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>'. $row[Agent_ID].'</td>';
echo '<td>'. $row[Address].'</td>';
echo '<td>'. $row[Bedrooms].'</td>';
echo '<td>'. $row[Price].'</td>';
}
echo '</table>';
?>
</body>
</html>

Now, if the output is: 'There are no entries inside the database' then there are no records in the table 'suburbs'. There are NO errors now, don't create errors for yourself.

ok thank you. i will try it now.

Yes, your script is wrong. I posted an altered version the script that fixed the errors you had.

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

Notice: Use of undefined constant Agent_ID - assumed 'Agent_ID' in F:\xampp\htdocs\movies4.php on line 23

Notice: Use of undefined constant Address - assumed 'Address' in F:\xampp\htdocs\movies4.php on line 24

Notice: Use of undefined constant Bedrooms - assumed 'Bedrooms' in F:\xampp\htdocs\movies4.php on line 25

Notice: Use of undefined constant Price - assumed 'Price' in F:\xampp\htdocs\movies4.php on line 26

<head>
</head>
<body>
<table border='1'>
<tr>
<th>Agent_ID</th>
<th>Address</th>
<th>Bedrooms</th>
<th>Price</th>
<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("ong_assessment", $connect);
$query = "SELECT Agent_ID,Address,Bedrooms,Price FROM suburbs";
$result = mysql_query($query) or die(mysql_error());
if(!mysql_affected_rows() >= 1)
{
echo 'There are no entries inside the database';
}

while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>'. $row['Agent_ID'].'</td>';
echo '<td>'. $row['Address'].'</td>';
echo '<td>'. $row['Bedrooms'].'</td>';
echo '<td>'. $row['Price'].'</td>';
}
echo '</table>';
?>
</body>
</html>

Better? They're no longer constants (:

yes!!! thank you very much. if i got pronlem again you will help me right?

Yes, but, try and solve the problems yourself :)! But, you're welcome to post here and we'll help you.

If this is solved, please mark it as solved and give rep to those who helped!

Good luck

now i need to write report about this php... any suggestion?

Member Avatar
diafol

WHat do you mean write a report?

Look at the syntax, if you have to explain what the script does, then it's pretty self-explanatory.. I cannot do your work for you, that wouldn't be fair and I'm sure you actually want to learn something ;) I'll help you a bit though:

  1. Explain what PHP is
  2. Explain the code you've written (So it retrives data from a table inside a database)
  3. Explain each line of code:

    $connect=mysql_connect("localhost","root","");
    $db_selected = mysql_select_db("ong_assessment", $connect);

This code establishes a connection with the database on the server. The mysql_connect accepts three parameters. The mysql_select_db attempts to select the database that data will be retrived from. It accepts two parameters, one is the name of the database and the other is the connection variable.

...

...

...

Something like this :)