Thanks for the help sijis ...
The $REQUEST['first']; and $REQUEST['last']; lines work perfectly! ... and I'm going to steal them from you! 🙂
When I tried the:
$sql = "SELECT * FROM faculty WHERE last_name = '$last' AND first_name = ''$first';
I got this error message:
Parse error: parse error, unexpected T_STRING in (php file) on line 38
... which is now from the error message line:
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
When I removed all the query error message code, I got the same
Parse error: parse error, unexpected T_STRING in (php file) on line 66
... which was this HTML line
<TR><TD><a href="mailto:<?php echo "$email"; ?>"><?php echo "$email"; ?></TD></TR>
which seems to perfectly work well when I only run the:
$sql = "SELECT * FROM faculty WHERE '$last'=`last_name` ";
line (... without an identical last name of course).
Thanks again for the suggestion and for the very tidy $_REQUEST[] method!
=========================== NEWEST CODE
<?php
//---------------------------------------------- CONNECT
$conn = mysql_connect("localhost", "directory", "****");
//---------------------------------------------- ERROR MESSAGES
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
};
if (!mysql_select_db("outpost")) {
echo "Unable to select mydb: " . mysql_error();
exit;
};
//---------------------------------------------- QUERY DATABASE
$_REQUEST['first'];
$_REQUEST['last'];
$sql = "SELECT * FROM faculty WHERE last_name = '$last' AND first_name = ''$first';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
extract($row);
};
//---------------------------------------------- ERROR MESSAGES
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
};
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
};
//---------------------------------------------- FREE MEMORY
mysql_free_result($result);
//---------------------------------------------- HTML PAGE
?>
<HTML>
<HEAD><TITLE>Directory</TITLE></HEAD>
<BODY>
<TABLE>
<TR><TD><?= $first_name ?> <?= $last_name ?></TD></TR>
<TR><TD><?= $division ?></TD></TR>
<TR><TD><?= $discipline ?></TD></TR>
<TR><TD><?= $location ?></TD></TR>
<TR><TD><?= $building_room ?></TD></TR>
<TR><TD><a href="mailto:<?php echo "$email"; ?>"><?php echo "$email"; ?></TD></TR>
</BODY>
</HTML>
Are you left handed? 🙂