News:

The "Support Requests" forum is now viewable by guests.

Main Menu

PHP MYSQL - Spot the Error?

Started by Osprey, May 18, 2006, 02:46:55 PM

Previous topic - Next topic

Osprey

I'm creating a search query. Both of the variables involved have been defined. It's displaying "Query Empty". Heres my code:


$searchq = "SELECT * FROM `TABLE` WHERE ('$searchin') = ('$searchfor')";


I've fiddeling around with this one little bit for most of today and it's getting frustrating. I've done search forms before and i've checked it against my search from before and can't see a difference except that i am using the "Search In" variable rather than always searching the same field and there is no limit to results. This shouldn't be a problem though?

I am searching for records that exist. Unfortionately i'm no php/mysql master :(

Any help much appreciated.

- Osprey

Osprey

LOL - It's always the most simple things. I'd been working on that for hours.. turns out i had an empty query line at the bottom! ARGH!

lotsofish

Whenever I have a problem with an SQL string, I echo it after it's set. That way I can see exactly what is being called. You can copy and paste it into phpMyAdmin then too and try to run the query. phpMyAdmin usually gives pretty good error texts.

Most likely, your $searchin or $searchfor vars aren't set right.

Osprey

Indeed. I often try and run them in PHPMYADMIN as it returns better error results.

I was echoing the variable also.

Turned out to be an empty query line i had completely forgotten about - Haha.