FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: Osprey on May 18, 2006, 02:46:55 PM

Title: PHP MYSQL - Spot the Error?
Post by: Osprey on May 18, 2006, 02:46:55 PM
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
Title: Re: PHP MYSQL - Spot the Error?
Post by: Osprey on May 18, 2006, 03:19:08 PM
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!
Title: Re: PHP MYSQL - Spot the Error?
Post by: lotsofish on May 19, 2006, 02:56:51 PM
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.
Title: Re: PHP MYSQL - Spot the Error?
Post by: Osprey on May 19, 2006, 03:29:53 PM
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.