I have an html file that is supposed to do a search and return of a database I have created in phpMyadmin but is giving me nothing but one error after another!!:'(
This is the html form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Directory List Request</title>
</head>
<body>
<form action="Database.php" method="post">
<input type="reset" value="Clear Form" />
<input type="submit" name="submit" value="send request" />
</form>
</body>
</html>
and it seems to work properly but the results I am getting are annoying as this calls several other php files designed to attach to and search through my database. The first of those files is this
<?php
require ('connect.php');
// create SQL statement
$sql = "SELECT lname, fname, areacode, telephone
FROM directory";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection);
// start results formatting
echo "<TABLE BORDER=1>";
echo "<TR><TH>lname<<TH>fname<<TH>areacode<<TH>telephone<";
// format results by row
while ($row = mysql_fetch_array($sql_result)) {
$lname = $row["lname"];
$fname = $row["fname"];
$areacode = $row["areacode"];
$phone = $row["telephone"];
echo "<TR><TD>$lname</TD><TD>$fname</TD><TD>$areacode</TD><TD>$phone</TR>";
}
echo "</TABLE>";
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
and I am not sure if it is working correctly as it is dependent on this script
<?php
// create connection
$connection = mysql_connect("localhost","zlloyd","");
// test connection
if (!$connection) {
echo "Couldn't make a connection!";
exit;
}
// select database
$db = mysql_select_db("Directory", $connection);
// test selection
if (!$db) {
echo "Couldn't select database!";
exit;
}
and again I am not sure if this is the problem but what I do know is that the output I am getting is incorrect:
lname< fname< areacode< telephone<
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\database.php on line 15
</TABLE>
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\database.php on line 26
and includes the errors that read expects parameter to be resource, boolean.:@
I cannot for the life of me see what is causing this and why the output is just lname, fname, areacode and telephone instead of the associated values from the database.:angry:
If anyone can tell me what is happening here I would be eternally grateful!!
P.S. I am fairly new to php and mysql so be gentle....