RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 700 | Replies: 3
Reply
Join Date: Mar 2007
Posts: 13
Reputation: rednarjess is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rednarjess rednarjess is offline Offline
Newbie Poster

Help error in myvehicle.php!

  #1  
Apr 30th, 2007
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>";
?>

//===========
Attached Files
File Type: zip DMV.zip (1.9 KB, 0 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: London
Posts: 42
Reputation: UrbanSky is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
UrbanSky UrbanSky is offline Offline
Light Poster

Re: error in myvehicle.php!

  #2  
Apr 30th, 2007
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
Reply With Quote  
Join Date: Apr 2007
Posts: 1
Reputation: justjoined is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
justjoined justjoined is offline Offline
Newbie Poster

Re: error in myvehicle.php!

  #3  
Apr 30th, 2007
Here you go
  1.  
  2.  
  3. <html>
  4. <head>
  5. <title>Displaying Your Vehicles</title>
  6. </head>
  7. <body>
  8. <?php
  9. $host = "localhost";
  10. $user = "";
  11. $password = "";
  12. $db = "";
  13. $table = "";
  14. mysql_connect($host,$user,$password) or die("Failed to connect");
  15. mysql_select_db($db) or die("Failed to select database");
  16. echo 'connected successfully';
  17. $sql = "SELECT * from $table ORDER BY id ASC;";
  18.  
  19. $result = mysql_query($sql);
  20. if ($row = mysql_fetch_array($result))
  21. {
  22. echo "<p align=\"center\"><font size=\"5\" color=\"#FF0000\">Your Vehicles:</font></p>";
  23. echo
  24. "<table border=\"1\" width=\"100%\" id=\"table1\">
  25. <tr>
  26. <th>
  27. <p dir=\"ltr\">Plate Number</th>
  28. <th>
  29. <p dir=\"ltr\">Vehicle Model</th>
  30. <th>
  31. <p dir=\"ltr\">Registration Date</th>
  32. <th>
  33. <p dir=\"ltr\">Expire Date</th>
  34. <th>
  35. <p dir=\"ltr\">More Info.</th>
  36. </tr>";
  37. do {
  38. echo "<tr>
  39. </tr>";
  40. echo " <tr>
  41. <th>$row[0]</th>
  42. <th>$row[1]</th>
  43. <th>$row[2]</th>
  44. <th>$row[3]</th>
  45. <th>$row[4]</th>
  46. </tr>";
  47. }
  48. while($row = mysql_fetch_array($result));
  49. echo"</table></div>";
  50. }
  51. else
  52. echo "<p><i><b><font face=\"Chiller\" size=\"6\" color=\"#FF0000\">Sorry dear</font><font face=\"Chiller\" size=\"5\" color=\"#800000\">,
  53. there is may be an error in our system, please contact us.</font></b></i></p>";
  54. ?>
  55.  
Reply With Quote  
Join Date: Mar 2007
Posts: 13
Reputation: rednarjess is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rednarjess rednarjess is offline Offline
Newbie Poster

Solution Solution: error in myvehicle.php!

  #4  
May 1st, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:01 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC