FreePgs.com Forum
December 07, 2021, 12:54:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Donate to FreePgs.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: PHP MYSQL - Spot the Error?  (Read 3051 times)
Osprey
Verified Account
Full Member
*

Karma: +0/-0
Offline Offline

Posts: 226

Blog entries (0)

View Profile WWW
« on: May 18, 2006, 10:46:55 AM »

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

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 Sad

Any help much appreciated.

- Osprey
Logged

Osprey
Verified Account
Full Member
*

Karma: +0/-0
Offline Offline

Posts: 226

Blog entries (0)

View Profile WWW
« Reply #1 on: May 18, 2006, 11:19:08 AM »

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!
Logged

FreePgs.com Forum
« Reply #1 on: May 18, 2006, 11:19:08 AM »

 Logged
lotsofish
Verified Account
Jr. Member
*

Karma: +1/-0
Offline Offline

Posts: 39

Blog entries (0)

View Profile WWW
« Reply #2 on: May 19, 2006, 10:56:51 AM »

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.
Logged

Osprey
Verified Account
Full Member
*

Karma: +0/-0
Offline Offline

Posts: 226

Blog entries (0)

View Profile WWW
« Reply #3 on: May 19, 2006, 11:29:53 AM »

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.
Logged

FreePgs.com Forum
« Reply #3 on: May 19, 2006, 11:29:53 AM »

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!