0

Hi All,

I'm having a problem with a query - which is based on conditional user inputs. In all circumstances, the outputted query ALWAYS works in phpmyadmin returning rows where applicable, but not always in php. No errors are displayed, with error reporting set at E_ALL, and mysql_error hasn't been invoked.

Here is my an example query which works only in phpmyadmin, returning rows. But not php.

SELECT * FROM product p LEFT JOIN product_info pi ON p.product_id=pi.product_id LEFT JOIN product_param pp ON p.product_id=pp.product_id WHERE spherelowneg<=-5 AND spherehighneg>=-5 AND sphere_low<=5 AND sphere_up>=5 AND cyllowneg<=-5 AND cylhighneg>=-5 AND cyllowneg<=-5 AND cylhighneg>=-5 AND axis_low<=160 AND axis_high>=160 AND axis_low<=70 AND axis_high>=70 AND pd_low<=60 AND pd_high>=60

in php, the query looks like this

$db=mysql_query("SELECT * FROM product p LEFT JOIN product_info pi ON p.product_id=pi.product_id LEFT JOIN product_param pp ON p.product_id=pp.product_id 
WHERE $spherelow<='$sphere' AND $spherehi>='$sphere'
AND $spherelowl<='$spherel' AND $spherehil>='$spherel' 
AND $cylfieldlow<='$maxcyl' AND $cylfieldhigh>='$maxcyl' 
AND $cylfieldlowl<='$maxcyll' AND $cylfieldhighl>='$maxcyll' 
AND axis_low<='$maxaxis' AND axis_high>='$maxaxis'
AND axis_low<='$maxaxisl' AND axis_high>='$maxaxisl'
AND pd_low<='$maxpd' AND pd_high>='$maxpd'") or die(mysql_error());

Any Ideas why this might be? I realise the query below checks columns several times.

Many Thanks

Edited by stevo356

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Yeah, it returns rows every time. All the values are escaped in php also.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.