Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 700 | Replies: 3
![]() |
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
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> </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 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> </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>";
?>
//===========
•
•
Join Date: Oct 2006
Location: London
Posts: 42
Reputation:
Rep Power: 3
Solved Threads: 4
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
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
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Here you go
php Syntax (Toggle Plain Text)
<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>"; ?>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode