[SOLVED] Query Help - Not getting the Records I expect

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Lenn
Forum Newbie
Posts: 2
Joined: Mon Oct 25, 2004 12:46 pm

[SOLVED] Query Help - Not getting the Records I expect

Post by Lenn »

I'm helping a friend with their website. It's being hosted by a local company.

It is a PHP server, and mysql database -- I'm not sure if it's apache or IIS.

So anyway, I'm running the following query under a test dir on the website:

$query = "select * from CARS where PRICE<$PRICE and CRCAT='".$CRCAT."'";

I receive no errors, or warnings .. but it's returning all records - not those that are lower than the price.

I echo out the variable .. and this is it's value:
select * from CARS where PRICE<5000 and CRCAT='Used'

I get 'used' cars ..but I also get cars in price well over 5000.

PRICE is a bigint(5), and CRCAT is varchar(5)

Can anyone suggest anything that might help me fix this, and get the output I want?

Thank you...

~Lenn
Last edited by Lenn on Mon Oct 25, 2004 5:28 pm, edited 2 times in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Run the query in the mysql console and see if it return the rows you expect. If it does then problem lies in your php code. Honestly I can't believe mysql could misbehave this way, but who knows...
Lenn
Forum Newbie
Posts: 2
Joined: Mon Oct 25, 2004 12:46 pm

Post by Lenn »

After spamming gratuitous echo statements .. I determined that my query was being over written.

Thanks for the help.

~Lenn
Post Reply