help me find the error..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alisyah
    New Member
    • May 2008
    • 9

    help me find the error..

    [HTML]
    <form action="result. php" method="post">
    <table width="61%" border="1" cellspacing="0" cellpadding="0" >
    <tr>
    <td width="22%">Tim e</td>
    <td width="78%">
    <select name="masa" id="masa" >
    <option selected>Time</option>
    <option>8:30</option>
    <option>9:30</option>
    <option>10:30 </option>
    <option>11:30 </option>
    <option>12:30 </option>
    <option>1:30</option>
    <option>2:30</option>
    <option>3:30</option>
    <option>4:30</option>

    </select> </td>
    </tr>
    <tr>
    <td>Day</td>
    <td><input name="hari" type="text" id="hari" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="search" id="search" value="search" /></td>
    </tr>
    </table>
    </form>[/HTML]


    [PHP]<?php

    if(isset($_POST["submit"]))
    {

    mysql_connect(" localhost","roo t","");
    mysql_select_db ("projek");

    $hari = $_POST["hari"];
    $masa =$_POST["masa"];
    $search =$_POST["search"];

    $query = "SELECT * FROM bt1 where $masa LIKE '$search'";
    $result = mysql_query($qu ery);

    echo "<br><br>";
    echo "<table border=1 width=100%>";
    echo "<tr bgcolor='pink'> ";
    echo "<td>Day </td>";
    echo "<td>Time </td>";
    echo "<td>Availabili ty </td>";
    echo "</tr>";

    $no=0;
    while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
    {
    $no++;
    echo "<tr>";
    echo "<td>{$row['hari']} </td>";
    echo "<td>{$row['masa']}</td>";
    echo "<td>{$row['availability']} </td>";
    echo "</tr>";
    }
    echo "</table>";

    }

    ?>[/PHP]
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    No.

    Firstly you're question suggests no politeness.

    Secondly, how are we supposed to know what the error is?

    Comment

    • alisyah
      New Member
      • May 2008
      • 9

      #3
      to marcus: i'm sorry if i'm being rude..i didn't mean it..i understand if u don't want help me..i have no idea to find the error..that's why i'm posting here..i understand if u were upset..you can ignore my post.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        First posting this bunch of code and not telling us what the error is? If you want us to help you, you have to tell us what the error, or supposed error is! This is not a guessing game. And withdrawing your post is not the answer to your problem.

        So state your problem and describe the error or whatever it is that is the problem.

        moderator

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Hi.

          For us to be able to help we need to know a few things...
          Like:

          What exactly is the problem?
          What is your code not doing that it should be doing?
          Are you getting any error messages?

          Have you tried to solve this yourself?
          What did you try? How/why did it fail?

          And please try to follow the Posting Guidelines at all times.

          Comment

          • alisyah
            New Member
            • May 2008
            • 9

            #6
            i'm sorry for my mistake.
            actually,i'm trying to create a search engine for my user to search data through my database but i keep getting error


            Code:
            Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\project\result.php on line 30
            Last edited by alisyah; May 26 '08, 12:28 AM. Reason: i'm being politeness

            Comment

            • TheServant
              Recognized Expert Top Contributor
              • Feb 2008
              • 1168

              #7
              Originally posted by alisyah
              [PHP]while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
              {...[/PHP]
              I am confused here? You are defining your $row array inside a while loop?
              It needs to be defined outside and a real condition put into the while parameter. My apologies if it is just me, but I don't see the logic.

              Comment

              • rpnew
                New Member
                • Aug 2007
                • 189

                #8
                Hi,

                @alisyah
                This error is because there is some problem in your query.. syntax error... and i can see problem in your query at only one place.... your query is as below

                [CODE=mysql]
                $query = "SELECT * FROM bt1 where $masa LIKE '$search'";
                [/CODE]

                here in WHERE clause you need to provide column name from your table (bt1) and you are providing variable, so make sure that you are getting the correct column name.

                So echo your query on page and paste it in MySql environment.. and get the error if any...

                @TheServant
                You can do that... by this way you will get all the fetched result.... from the database...

                Comment

                • dlite922
                  Recognized Expert Top Contributor
                  • Dec 2007
                  • 1586

                  #9
                  Originally posted by TheServant
                  I am confused here? You are defining your $row array inside a while loop?
                  It needs to be defined outside and a real condition put into the while parameter. My apologies if it is just me, but I don't see the logic.

                  its not "inside" the while loop, but in the condition, hence it works.

                  Each time it is called, mysql_fetch_ass oc() will return the next row....by Magic! :)

                  Dan

                  Comment

                  • alisyah
                    New Member
                    • May 2008
                    • 9

                    #10
                    thanks everybody..
                    i think i can fix it..
                    thanks so much..
                    i've learned a lot here..^^

                    Comment

                    • TheServant
                      Recognized Expert Top Contributor
                      • Feb 2008
                      • 1168

                      #11
                      Originally posted by alisyah
                      thanks everybody..
                      i think i can fix it..
                      thanks so much..
                      i've learned a lot here..^^
                      Good. Post your final solution so others can learn from it. I learned something too! Magic!

                      Comment

                      Working...