On Fri, 27 Apr 2001 14:27, waro wrote:
> Hello,
>
> I just learn PHP for a month now. It's hard for me
> since I have no background in programming (I do HTML
> but this is totally different).
> Last few days I try to make a simple script so
> visitors can search my site. I use a MySQL database
> here and there are some tables to handle my other PHP
> works. The "search" table contains: words_id, words,
> path_id, file_id, and info fields.
>
> This is my snippet:
> <?php//search.php
> // Connect to database
> include "db.php";
> // Looking for the right word
> $query = mysql_query ("SELECT search.words_id,
> search.words, search.path_id, search.file_id,
> search.info, tips.tips, path.path_id, path.path,
> filename.file_id FROM search, tips, path, filename
>                       WHERE words LIKE '%$search%', search.path_id =

I think part of your problem may be in the WHERE clause above, where you 
use a comma  instead of (I think) AND


> path.path_id AND search.file_id = filename.file_id
>                       ORDER BY words_id");
> if (empty($query)){
>               echo "<P>Sorry, no matching ...</P>";
>       }
> else {// Display search
>       while ($hasil = mysql_fetch_array($query)){
>               echo "<P><A
> href=\"$hasil[path]/tip.php?file_id=$hasil[file_id]&tips=$hasil[tips]\"
>>$hasil[tips]</A>"; echo "$hasil[info]</P>\n";

and then this may cause a problem: you should enclose the array indices 
in " thus - $hasil["path]" so PHP doesn't get confused whether they are 
constants or not.

>       }
> }
> ?>
>
> And here's my search form:
>   <FORM method="GET" action="search.php">
>      <INPUT type="text" name="search" size="15">
>      <INPUT type="submit">
>   </FORM>
>
> But I always get the "Sorry, no matching ..." output
> even though my SQL table has the word in its field.
> Would someone help me with this. Any suggestion, hints
> or tips will help me so much.
>
> Thank you in advance,

A general tip - whenever you are having trouble with a SQL you can echo 
the actual query and (if you can) feed it directly to the database engine 
or (for MySQL) use mysql_error() after any calls to the database 
functions to return an error string.

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   Bad breath is better than no breath.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to