SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2001
    Location
    Holland
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi again,

    I'm having a little quotation problem, i've read a nice tutorial about variables and how to use them and now knowing this I thought I could make my (not complex) database a searchable one.

    Now i've made a <form> wich put the search text in a $sid variable and gets it.. (buttonname search value search)
    then i've used "

    if ($search == search) { $cruel=SELECT naam, links, rechts, date FROM appel . WHERE naam LIKE $sid;

    $db2 = mysql_query($cruel); }

    This isn't gonna work, since a mysql_query should be(" enter a mysql console command here ")

    Is there something i'm missing?

  2. #2
    SitePoint Member
    Join Date
    May 2001
    Location
    Holland
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhm, i could also ask, how to put a variable in a mysql command

    oh because I was just bashing out code, I forgot the % around $id

  3. #3
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand what the problem is...

    but shouldn't the code look like this:
    PHP Code:
    if ($search == search) { 
      
    $cruel="SELECT naam, links, rechts, date FROM appel . WHERE naam LIKE $sid"

      
    $db2 mysql_query($cruel); 

    You can read the values in $db2 like this:
    PHP Code:
    $naam     mysql_result($db2,0,'naam');
    $links     mysql_result($db2,0,'links');
    $rechts     mysql_result($db2,0,'rechts');
    $date     mysql_result($db2,0,'date');

    print 
    "$naam$links$rechts$date"
    You can now print the variables

  4. #4
    SitePoint Member
    Join Date
    May 2001
    Location
    Holland
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For sql, u need to quote your LIKE input.. like this:

    -->SELECT Text FROM table1
    -->WHERE Text LIKE "%this%";

    This will output every row of text containing the word this.

    Now, i want to put "%$Search%" in a variable. This way you can interactivly search the database..

    I happen to know another way around, but that's copying an pasting code.. that will help untill my nextproblem.. so I'm not learning here..

  5. #5
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put \ in front of "
    like: WHERE Text LIKE \"%this%\" (see beneath how it looks in PHP)

    PHP Code:
    WHERE Text LIKE \"%this%\" 
    The parser will disregard the quotes...

  6. #6
    SitePoint Member
    Join Date
    May 2001
    Location
    Holland
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool thanx!!

  7. #7
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No probs...

    It goes for any special character that is also used in PHP coding...

    Good luck with your search engine


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •