Im having trouble with this simple search.
<?php
$submit=$_POST[submit];
$pid=$_GET[pid];
$PHP_SELF=$_POST[PHP_SELF];
$searchtype=$_POST[searchtype];
$searchstring=$_POST[searchstring];
if ($searchstring)
{
$db = mysql_connect("localhost", "webuser", "");
$sql="SELECT * FROM js_content WHERE $searchtype LIKE '%$searchstring%' ORDER BY counter ASC";
mysql_select_db("learndb",$db);
$result = mysql_query($sql,$db);
echo "<TABLE BORDER=2>";
echo"<TR><TD><B>Full Name</B><TD><B>Nick Name</B><TD><B>Options</B></TR>";
while($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>".$myrow["title"]." ".$myrow["subtitle"]."<TD>".$myrow["thumb"];
echo "<TD><a href=\"view.php?pid=".$myrow["pid"]."\">View</a>";
}
echo "</TABLE>";
}
else
{
?>
<form method="POST" action="<?php $PHP_SELF ?>">
<table border="2" cellspacing="2">
<tr><td>Insert you search string here</td>
<td>Search type</td></tr>
<tr>
<td><input type="text" name="searchstring" size="28"></td>
<td><select size="1" name="searchtype">
<option selected value="title">title</option>
<option value="lastname">Last Name</option>
<option value="nick">Nick Name</option>
<option value="email">Email</option>
</select></td>
</tr>
</table>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<?php
}
?>
</HTML>
I get this error in my log.
[Fri Aug 15 19:55:35 2003] [error] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/htdocs/joesmut.com/virtualhost/members/search.php on line 16
A smaller concern that im not worried about right now but if an answer can be made I would be happy to. I get these errors on most of my scripts. They dont harm anything. Just curiouse of why?
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Use of undefined constant submit - assumed 'submit' in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 2
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Undefined index: submit in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 2
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Use of undefined constant pid - assumed 'pid' in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 3
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Undefined index: pid in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 3
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 4
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Undefined index: PHP_SELF in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 4
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Use of undefined constant searchtype - assumed 'searchtype' in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 5
[Fri Aug 15 19:55:35 2003] [error] PHP Notice: Use of undefined constant searchstring - assumed 'searchstring' in /var/www/htdocs/asdf.com/virtualhost/members/search.php on line 6