This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Aug 21, 2011 7:20 pm


Postby mysterio864 » Sun Aug 21, 2011 7:26 pm

Hello everyone!

I am having a hard time with this code and I hope that someone can help me:

<title>Search Application Form</title>
<link href="css.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="script.js"></script>
<base target="_self">
include "connect.php";
include "validatelogin2.php";
<body id="body2">
<FORM method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table id="table2">
<tr><td width="50">Search:</td><td><INPUT type="text" name="searchstring" framewidth="4" size="20"></td></tr>
<tr><td width="50">Within:</td>
<td><select name="searchtype">
<option value="sname">School</option>
<option value="remarks">Remark</option>
<option value="lname">Last Name</option>
<option value="fname">First Name</option>
<option value="mobile">Mobile</option>
<option value="email">Email Adress</option>
<option value="id">ID #</option>
<INPUT type="Reset" value="Clear"> <INPUT type="submit" value="Search" name="Submit">
<table id="table3" border=1 cellpadding=1 cellspacing=1 bordercolor="#000000" align="center">
<tr bgcolor='#9999FF'>
<td><center><font color="#ff0000"><b>#</b></font></center></td>
<td><center><font color="#ff0000"><b>Full Name</b></font></center></td>
<td><center><font color="#ff0000"><b>Academic Institution</b></font></center></td>
<td><center><font color="#ff0000"><b>Email</b></font></center></td>
<td><center><font color="#ff0000"><b>Mobile Number</b></font></center></td>
<td><center><font color="#ff0000"><b>Remarks</b></font></center></td>
<td><center><font color="#ff0000"><b>Date Added</b></font></center></td>
<td><center><font color="#ff0000"><b>Added By</b></font></center></td>
$searchstring = $_POST['searchstring'];
$searchtype = $_POST['searchtype'];
if($searchstring == ""){
echo "<h3><center>Empty Search Box</h3>";
$sql=mysql_query("SELECT application.lname, application.fname, application.sname,,, remark.remarks, remark.dateadded, remark.addedby FROM application WHERE application.$searchtype LIKE 'application.%$searchstring%' LEFT JOIN remark ON ''='' ORDER BY remark.dateadded desc, application.sname, application.lname, application.fname;");
if(mysql_num_rows($sql) == "0"){
echo "<h3><center>Query not found.</h3></center>";
while ($row=mysql_fetch_array($sql)){
<td><?php echo $i; $i++; ?></td>
<td><a href="solo.php?id=<?php echo $row['id']; ?>"><?php echo $row['appplication.lname']; ?>, <?php echo $row['appplication.fname']; ?></a></td>
<td><?php echo $row['appplication.sname']; ?></td>
<td><a href="mailto:<?php echo $row['']; ?>"><?php echo $row['']; ?></a></td>
<td><?php echo $row['']; ?></td>
<td><?php echo $row['remark.remarks']; ?></td>
<td><?php echo $row['remark.dateadded']; ?></td>
<td><?php echo $row['remark.addedby']; ?></td>
<?php } } } } ?>

Because when I am trying to search within the database the following error occurs:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\hri\weusa\remarksearch2.php on line 52

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\hri\weusa\remarksearch2.php on line 55

please help..

New php-forum User
New php-forum User
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Re: PHP-MYSQL help

Postby lokanath7 » Wed Aug 24, 2011 7:52 am

mysql_num_rows() returns change ur line

if(mysql_num_rows($sql) == "0")


if(mysql_num_rows($sql) == 0){

Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest