Home » Performance » MySQL » issue with Search feature using MySQL and PHP
issue with Search feature using MySQL and PHP [message #2923] Wed, 09 April 2008 18:09 Go to next message
pulse88  is currently offline pulse88
Messages: 4
Registered: April 2008
Junior Member
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
Re: issue with Search feature using MySQL and PHP [message #2925 is a reply to message #2923 ] Wed, 09 April 2008 23:32 Go to previous messageGo to next message
debug  is currently offline debug
Messages: 132
Registered: March 2008
Senior Member

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.


Mikhail Solovyev, MySQL Performance Expert
MySQL Performance Blog
MySQL Consulting
Re: issue with Search feature using MySQL and PHP [message #2926 is a reply to message #2925 ] Wed, 09 April 2008 23:42 Go to previous messageGo to next message
pulse88  is currently offline pulse88
Messages: 4
Registered: April 2008
Junior Member
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?
Re: issue with Search feature using MySQL and PHP [message #2927 is a reply to message #2926 ] Wed, 09 April 2008 23:48 Go to previous messageGo to next message
debug  is currently offline debug
Messages: 132
Registered: March 2008
Senior Member

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.


Mikhail Solovyev, MySQL Performance Expert
MySQL Performance Blog
MySQL Consulting
Re: issue with Search feature using MySQL and PHP [message #2928 is a reply to message #2927 ] Thu, 10 April 2008 00:13 Go to previous messageGo to next message
pulse88  is currently offline pulse88
Messages: 4
Registered: April 2008
Junior Member
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.
Re: issue with Search feature using MySQL and PHP [message #2929 is a reply to message #2928 ] Thu, 10 April 2008 00:28 Go to previous messageGo to next message
debug  is currently offline debug
Messages: 132
Registered: March 2008
Senior Member

Hmm, I am not css guru at all Smile
But maybe you can use such workaround:

CSS: td.with_hover: hover { background color: #dddddd;}
HTML: something like <td class="td.with_hover"> ?


Mikhail Solovyev, MySQL Performance Expert
MySQL Performance Blog
MySQL Consulting
Re: issue with Search feature using MySQL and PHP [message #2930 is a reply to message #2929 ] Thu, 10 April 2008 02:03 Go to previous message
pulse88  is currently offline pulse88
Messages: 4
Registered: April 2008
Junior Member
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 <span> 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.
Previous Topic:multiple inserts at the same time.
Next Topic:ndb size
Goto Forum:
  


Current Time: Fri Jul 10 00:40:29 EDT 2009

Total time taken to generate the page: 0.02716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.