Page 1 of 1

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

Posted: Mon Oct 25, 2004 12:54 pm
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

Posted: Mon Oct 25, 2004 1:03 pm
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...

Posted: Mon Oct 25, 2004 5:33 pm
by Lenn
After spamming gratuitous echo statements .. I determined that my query was being over written.

Thanks for the help.

~Lenn