GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

issue with Search feature using MySQL and PHP

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • issue with Search feature using MySQL and PHP

    hey all,
    I'm a newbie with mysql and php as well as this site. I came here as a last resort to find a solution to a small independent project that I'm working on.

    Background:
    I have a MySQL database created/filled and I'm using php to connect to the db. I'm currently working on the search feature on the site. This is new to me so I'm running into some errors.

    Problem:
    I want to be able to input any text for search (ignoring the security risks with that at this point for testing) and have it search all the columns of the table, so basically I got stuck on the WHERE clause in the query. I know that I can use WHERE a_column LIKE \"%$srchtxt%\" OR another_column LIKE \"%$srchtxt%\" etc...
    But doing this I could only put three/four OR operands after which I'll get an error that says: " mysqli_fetch_row() expects parameter 1 to be mysqli_result.

    I thought there's a certain way to do this, so I have limited info here otherwise I can put more code/info.

    Thanks for your time,
    -me

  • #2
    I can recommend you first do the following: make your PHP script output query on screen. And then run this query in MySQL client manually. I do not think that 3-4 OR statements is the limit, but most probably there is some syntax error in the query. Please try this and let me know.

    Comment


    • #3
      hey thanks, man!

      yes, it was a minor syntax error. u have to be an idiot to believe that MySQL has limits like that huh.haha. O' the newbies!

      so, the search feature is working just fine. and the question can be considered answered

      While I'm at it. let me ask another question:
      what is the best way to handle a set of pictures (that could potentially be sent by ANY user online) to be stored/accessed in the database. I understand that you can't store an image! but what other options are there:

      There's only one i can think of:
      use an auto increment ID as a reference and save all the files as 1.jpg, 2.jpg, so on...tedious but probably works. Then again, how does a user send a picture to be stored to the database through some kind of form? any ideas?

      Comment


      • #4
        Heh, actually you can store image in database (take image file, base64 encode it, and store in database), but it is not very good for high performance.
        More often images are stored in separate folder, and database has list of images and files names. You can use incrementing id, or some function which generates filename based on date and random functions, and so on.
        What about uploading images - please see http://ru2.php.net/manual/en/features.file-upload.php about file upload in PHP. As you want to store list of images in database, you should do one database insert after file upload is completed.

        Comment


        • #5
          oh, i'll look into that soon.
          and thanks for the link to the php file handling. I never knew that. I've been on a discovery lane lately..to say the least PHP and MySQL is close to godliness for me now!

          At this point, i know i've gone out of topic already. But if u(or anyone else) cud share any CSS widsom. here goes my question: I want to have a hover property for rows in a table i created and I've used an external style sheet so far. When I use it, it works just great but i get BONUS with that i,e. since the entire page is in a table format(i know, newbie!) the rows of the page layout also show that hover property. I understand WHY but any way around this? any 'div' tricks..
          i used:

          td: hover { background color: #dddddd;}

          Today's been amazingly productive for me and everything just working bam bam bam! love it!
          Thanks fr yr help and links.

          Comment


          • #6
            Hmm, I am not css guru at all )
            But maybe you can use such workaround:

            CSS: td.with_hover: hover { background color: #dddddd;}
            HTML: something like ?

            Comment


            • #7
              whew!...finally.
              I was trying exactly what you told me. and that was a good start. It made sense but didn't work exactly.
              After several searches on CSS examples and an hour of work, I used tags instead which did wonders!

              i finally get to sleep now...

              hey, thanks for the continuous help. I'll be bugging you guys more over the week/end.

              Comment

              Working...
              X