my search page is not work in server

Discussion in 'PHP' started by abosirage, Nov 18, 2010.

  1. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    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 a moderator: Nov 18, 2010
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  3. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    dear Shabbir
    I am very sorry I didn't get you
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Nor did I get your error.
     
  5. abosirage

    abosirage Member

    Joined:
    Jul 29, 2010
    Messages:
    34
    Likes Received:
    0
    Trophy Points:
    6
    Occupation:
    IT
    Location:
    Tripoli-Libya
    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
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Again I assume the issue is with the Query. Print your SQL Query. I think the variable searchtype is not initialized.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice