Thanks jrolands and The Defender.
The script is now working and I am getting results, but I am also getting Warning: mysql_fetch_array(): 6 is not a valid MySQL result resource in C:\wamp\www\testphp.php on line 70. I highlighted Line 70 and the code around it in red, below.
Can you tell me what that might mean?
Here is the new script:
<html>
<head>
<title>LOC Member Search</title>
</head>
<body>
<h>Search By Member Name</h>
<form method="post" action="<?php echo $PHP_SELF;?>">
Enter All or Part of Last Name:   <input type="text" name="l_name" value=""><br>
Enter All or Part of First Name:   <input type="text" name="f_name" value="">
<br><br>
<p>Search By City and/or State</p>
<?php
//connect to database
$link = mysql_pconnect('localhost', 'xxxxx', 'xxxxx');
if (!$link) {die('Could not connect: ' . mysql_error());}
mysql_select_db("loc", $link);
// put city data in dropdown menu
$city_res = mysql_query("SELECT city FROM address ORDER BY city")
or die("Invalid query: " . mysql_query());
echo '<label>Select City:  </label>';
echo '<select id="city" name="city">';
echo '<option value=""> ------------ </option>';
while ($row = mysql_fetch_assoc($city_res)) {
$city = $row['city'];
echo "<option value='$city'>$city</option>";
}
echo '</select>';
echo '          ';
// put state data in dropdown menu
$state_res = mysql_query("SELECT state FROM address ORDER BY state")
or die("Invalid query: " . mysql_query());
echo '<label>Select State: </label>';
echo '<select id="state" name="state">';
echo '<option value=""> ------------ </option>';
while ($row = mysql_fetch_assoc($state_res)) {
$state = $row['state'];
echo "<option value='$state'>$state</option>";
}
echo '</select>';
?>
</select><p><p>
<input name="submit" value="Submit" type="submit">
</form>
<?php
//connect to database
$link = mysql_pconnect('localhost', 'xxxxx', 'xxxxx');
if (!$link) {die('Could not connect: ' . mysql_error());}
mysql_select_db("loc", $link);
$in_lname = $_POST["l_name"];
$get_member_sql = "SELECT mbr_id, f_name, l_name from member_name where l_name like '%$in_lname%'";
$get_member_res = mysql_query($get_member_sql, $link)
or die("Invalid query: " . mysql_error());
if (mysql_num_rows($get_member_res) >0) {
[COLOR="Red"]while ($member_info = mysql_fetch_array($get_member_res))
{$mbr_id = ($member_info['mbr_id']);
$f_name = ($member_info['f_name']);
$l_name = ($member_info['l_name']);
$display_member .= "<p>$mbr_id<br>$f_name<br>$l_name</p>";
echo $display_member;[/COLOR]
//free result
mysql_free_result($get_member_res);
}
}
?>
</body>
</html>