Search returning empty results
Posted: Sat May 16, 2009 9:23 am
I am trying to have a simple motor vehicle registration search page where you type in a tag and it returns the basic vehicle information for a school to use. I got everything done but when I search, it returns the table I have made with the headings and so forth, but nothing is being pulled from the database. It's been several years since I've worked with PHP and probably is just one small thing I am missing, but here is my code.
Code: Select all
<?php
$con = mysql_connect("host","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("shb12_041_2", $con);
$sql=("SELECT * FROM mvr WHERE plate = $_POST['plate']");
$result=mysql_query($sql) or die("Error in selecting the database:".mysql_error());
$row=mysql_fetch_row($result);
$ownername = $row['ownername'];
$plate = $row['plate'];
$expiration = $row['expiration'];
$address = $row['address'];
$citystatezip = $row['citystatezip'];
$bodytype = $row['bodytype'];
$year = $row['year'];
$make = $row['make'];
$model = $row['model'];
echo "<table border=1>";
echo "<tr><td align=top><small>Owner Name</small><br>$ownername</td><td align=top><small>Current Plate</small><br>$plate</td><td align=top><small>Expiration</small><br>$expiration</td><td align=top><small>Address</small><br>$address</td></tr>";
echo "<tr><td align=top><small>City/State/Zip</small><br>$citystatezip</td><td align=top><small>Body Type</small><br>$bodytype</td><td align=top><small>Year</small><br>$year</td><td align=top><small>Make</small><br>$make</td></tr>";
echo "<tr><td align=top><small>Model</small><br>$model</td><td align=top><small>Color</small><br>$color</td><td align=top><small>Stolen</small><br>$stolen</td><td align=top></td></tr>";
mysql_close($con);
?>