Hi there. I've got a couple of problems that I need a hand with.
First, I get two warnings as follows:
"Warning: Supplied argument is not a valid MySQL result resource." This occurs on line 47.
Line 47 is: $row = mysql_fetch_object($result);
"Warning: Supplied argument is not a valid MySQL result resource." This occurs on line 32.
Line 32 is: $num_rows = mysql_num_rows($result);
Second and perhaps a more serious problem:
During membership sign-up several questions are answered and optional fields not answered (ie: those left blank) are entered as "no" into the database.
However, during a search on the same criteria that users use to sign up. However, if a user decides to select "No preference." I need the ability to search not just those with "no" in it BUT all records in with any content in it.
Here's my coding and I appreciate your help!
<?PHP
session_start();
include("dblib.inc");
include("dynamicmenu.inc");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Search results</title>
<Link href="arial.css" rel=stylesheet title=arial type=text/css>
<body>
<BR>
<img src="pics/logo.gif"><BR>
<BR>
<?PHP
//query for matches
$query = "SELECT CFirstName,CLastName,CEmail,CCity
FROM clients,interests
WHERE (I1 = '$Interests' OR I2 = '$Interests' OR I3 = '$Interests' OR I4 = '$Interests' OR I5 = '$Interests' OR I6 = '$Interests' OR I7 = '$Interests')
AND CCity = '$CCity' ORDER BY CCity, CLastName
AND CPics = '$CPics'
AND CEyeColor = '$CEyeColor'
AND CHairColor = '$CHairColor'
AND CKids = '$CKids'
AND CBody = '$CBody'
AND CEducation = '$CEducation'
AND CChurch = '$CChurch'
";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
print "Found $num_rows profiles that matched your search criteria.<BR><BR>";
//Prints out the results of your query
print "<table border=1 cellpadding=5 cellspacing=0>";
print "<TR>";
print "<TD><B>#</b></td>";
print "<TD><B>Name</b></td>";
print "<TD><B>Email</b></td>";
print "<TD><B>City</b></td>";
print "</tr>";
for ($loopvar=0; $loopvar<$num_rows; $loopvar++)
{
//This queries others with the same interests
$row = mysql_fetch_object($result);
$tempvar = $loopvar+1;
print "<tr>";
print " <TD>$tempvar</td>
<TD>$row->CFirstName $row->CLastName</td>
<TD>$row->CEmail</td>
<TD>$row->CCity</td>
<TD>
<font size=-1>
<B>Add to my buddy list</b>
</font>
</td>";
print "</tr>";
}
print "</table>";
print "<BR><BR>";
//This retrieves the variables from the previous forms
foreach ($HTTP_POST_VARS as $key=>$val)
if (gettype($val) == "array")
{
print "$key:<BR>\n";
foreach ($val as $two_dim_value)
print ".....$two_dim_value<BR>";
}
else
{
print "$key: $val<BR>\n";
}
?>
</body>