my search page is not work in server

abosirage's Avatar, Join Date: Jul 2010
Go4Expert Member
hi everybody
its me again help me if you can
my search page is not work in server please check my code below & find out what is wrong with it
Code:
<HTML>
<?php
include ('config.php');
if (isset($_POST['searchstring'])) 
{
 $sql="SELECT * FROM personnel WHERE $searchtype LIKE '%$searchstring%' ORDER BY firstname ASC";
 $result = mysql_query($sql);
 echo "<TABLE BORDER=0 align=center>";
 echo"<TR><td align=center width=190><B>الاجـــراء</B><td align=center width=190><B>الاسم واللقب</B><td align=center width=190><B>العنــوان</B></TR>";
while ($myrow = mysql_fetch_array($result))
 {
echo "<TR><td align=center><a href=\"view.php?id=".$myrow["id"]."\">عرض</a>";
 echo "<td align=center>".$myrow["firstname"]." ".$myrow["lastname"]."<td align=center>".$myrow["nick"];
 }
 echo "</TABLE>";
}
else
{
?>
<form method="POST" action="<?php $PHP_SELF ?>">
<table border="0" cellspacing="2" align=center>
<tr><td align=center width=190><b>مجال البحث</b></td>
<td align=center width=190><b>ادخل كلمة البحث</b></td></tr>
<tr>
<td align=center width=150>
<p dir="rtl"><select size="1" name="searchtype">
<option selected value="firstname">الاســـــم</option>
<option value="lastname">اللقــــب</option>
<option value="nick">العنوان</option>
<option value="email">البريد الالكتروني</option>
</select></td>
<td align=center width=150>
<p align="left" dir="rtl">
<input name="searchstring" size="22" style="float: right"></td>
</tr>
<tr><td colspan=3>
<p>&nbsp;&nbsp; <input type="submit" value="ابحث" name="B1" align=middle>&nbsp;&nbsp; <input type="reset" value="تراجع" name="B2">&nbsp; </p>
</td></tr>
</table>
<p align="center"><b><span lang="ar-sa"><a href="serch.php">بحث جديد</a>&nbsp;&nbsp;&nbsp;
<a href="viewdb.php">عودة للقائمة</a></span></b></p>
</form>
<?php
}
?>
</HTML>

Last edited by shabbir; 18Nov2010 at 14:56.. Reason: Code blocks
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You should learn how to post code by now. Read the link I have in the reason if you still don't know.

Second thing is you should be specific for what is not running. I see your code even with just opening and closing HTML tag can run on any server.
0
abosirage's Avatar, Join Date: Jul 2010
Go4Expert Member
dear Shabbir
I am very sorry I didn't get you
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Nor did I get your error.
0
abosirage's Avatar, Join Date: Jul 2010
Go4Expert Member
dear Shabbir

when I run above code my result is this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in .../serch.php on line 10
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Again I assume the issue is with the Query. Print your SQL Query. I think the variable searchtype is not initialized.