Dear all;
I write this php file and when I want to view it does not make sense. It also can't retrieve the necessasry info from my database:( . Please can any one guide me.
Note: I attached my DMV database.
Thanks alot
//===========
<html>
<head>
<title>Displaying Your Vehicles</title>
</head>
<body>
<?php
$host = "localhost";
$user = "";
$password = "";
$db = "DMV";
$table = "myvehicle";
mysql_connect($host,$user,$password) or die("Failed to connect");
mysql_select_db($db) or die("Failed to select database");

$sql = "SELECT * from $table ORDER BY id ASC;";
$result = mysql_query($sql);
if ($row = mysql_fetch_array($result))
{
echo "<p align=\"center\"><font size="5" color=\"#FF0000\">Your Vehicles:</font></p>";
echo
"<table border=\"1\" width=\"100%\" id=\"table1\">
<tr>
<th>
<p dir=\"ltr\">Plate Number</th>
<th>
<p dir=\"ltr\">Vehicle Model</th>
<th>
<p dir=\"ltr\">Registration Date</th>
<th>
<p dir=\"ltr\">Expire Date</th>
<th>
<p dir=\"ltr\">More Info.</th>
</tr>";
do {
echo "<tr>
</tr>";
echo " <tr>
<th>$row[0]</th>
<th>$row[1]</th>
<th>$row[2]</th>
<th>$row[3]</th>
<th>&nbsp;</th>
</tr>";
}
while($row = mysql_fetch_array($result));
echo"</table></div>";
}
else
echo "<p><i><b><font face=\"Chiller\" size="6" color=\"#FF0000\">Sorry dear</font><font face=\"Chiller\" size="5" color=\"#800000\">,
there is may be an error in our system, please contact us.</font></b></i></p>";
?>

//===========

First of all what do you mean it does not make sense? Please be a bit more specific in your question.

Secondly, does the script through any errors about connecting to the database as your have left the $user and $password blank I would assume that your have a username and password set (If not I would advise setting one, even on a dev box as it is god practice).

Urban

Here you go

<html>
<head>
<title>Displaying Your Vehicles</title>
</head>
<body>
<?php
$host = "localhost";
$user = "";
$password = "";
$db = "";
$table = "";
mysql_connect($host,$user,$password) or die("Failed to connect");
mysql_select_db($db) or die("Failed to select database");
echo 'connected successfully';
$sql = "SELECT * from $table ORDER BY id ASC;";

$result = mysql_query($sql);
if ($row = mysql_fetch_array($result))
{
echo "<p align=\"center\"><font size=\"5\" color=\"#FF0000\">Your Vehicles:</font></p>";
echo
"<table border=\"1\" width=\"100%\" id=\"table1\">
<tr>
<th>
<p dir=\"ltr\">Plate Number</th>
<th>
<p dir=\"ltr\">Vehicle Model</th>
<th>
<p dir=\"ltr\">Registration Date</th>
<th>
<p dir=\"ltr\">Expire Date</th>
<th>
<p dir=\"ltr\">More Info.</th>
</tr>";
do {
echo "<tr>
</tr>";
echo " <tr>
<th>$row[0]</th>
<th>$row[1]</th>
<th>$row[2]</th>
<th>$row[3]</th>
<th>$row[4]</th>
</tr>";
}
while($row = mysql_fetch_array($result));
echo"</table></div>";
}
else
echo "<p><i><b><font face=\"Chiller\" size=\"6\" color=\"#FF0000\">Sorry dear</font><font face=\"Chiller\" size=\"5\" color=\"#800000\">,
there is may be an error in our system, please contact us.</font></b></i></p>";
?>

I found the errors:
1) I forget to put slash before each size.
2) In sql command, there is a seimecolon inside which is wrong.
Thank for all for helping me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.