I am very new to working with PHP and could really use some help here. I am trying to write some php scripts that will display a text input box which will be used to search the database I have it connected to.
Right now, my problem is that the code I have keeps sending me to a page that says 'Object not found!' at the top with a 'Error 404' displayed towards the bottom. The code I am using for the page is the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTDxhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Campbell Sales</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<h1>Campbell Sales</h1>
<form name="form" action="search.php" method="get">
<input type="text" name="q" />
<input type="submit" name="Submit" value="Search" />
</form>
<?php
// Connect and select a database
// mysql_connect("localhost", "root", "");
// mysql_select_db("cambellsales");
$con = mysql_connect("", "root", "", "cambellsales");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("cambellsales", $con);
//Run a query
$result = mysql_query("SELECT * FROM inventory") or die("Query failed with error: ".mysql_error());
echo "<table border='1' cellpadding='8' cellspacing='3'
summary=\"Table holds Cambell inventory information\">
<tr>
<th>isle</th>
<th>col</th>
<th>r</th>
<th>rows</th>
<th>quantity</th>
<th>partnumber</th>
<th>surplus</th>
<th>description</th>
<th>cost</th>
<th>entryorder</th>
<th>icrr</th>
<th>irrc</th>
<th>rowm</th>
</tr>";
// Loop through all table rows
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['Isle'] . "</td>";
echo "<td>" . $row['Col'] . "</td>";
echo "<td>" . $row['R'] . "</td>";
echo "<td>" . $row['Row'] . "</td>";
echo "<td>" . $row['Quantity'] . "</td>";
echo "<td>" . $row['PartNumber'] . "</td>";
echo "<td>" . $row['Surplus'] . "</td>";
echo "<td>" . $row['Description'] . "</td>";
echo "<td>" . $row['Cost'] . "</td>";
echo "<td>" . $row['EntryOrder'] . "</td>";
echo "<td>" . $row['ICRR'] . "</td>";
echo "<td>" . $row['IRRC'] . "</td>";
echo "<td>" . $row['RowM'] . "</td>";
echo "</tr>";
}
// Free result memory and close database connection
mysql_free_result($result);
mysql_close($con);
?>
</table>
</body>
</html>