mboucher Posted March 18, 2009 Share Posted March 18, 2009 Hi, I have a query with some parameters, but one of them is not working correctly, it just seems to ignore it completely. No matter what you enter in it, it returns ALL results. I've verified the query by running it manually and it should work fine. The parameter that doesn't work is the ItemCode one. <TD class=middle>Item Code:</TD> <TD colspan=1 class=middle> <input class=input size=15 align=middle type=text name=Itemcode value=$ItemCode> if ($dosearch) { if ($GroupCode == "-1") $GroupCodeCriteria = ""; else $GroupCodeCriteria = "and i.itmsgrpcod=" . $GroupCode; $ItemNameCriteria = "and i.itemname like '%$ItemName%'"; $ItemCodeCriteria = "and i.ItemCode like '%$ItemCode%'"; $sql = "select i.ItemCode, i.ItemName, i.OnHand, i.IsCommited, i.OnOrder, g.itmsgrpnam as GroupName from OITM i, OITB g where i.itmsgrpcod = g.itmsgrpcod $GroupCodeCriteria $ItemNameCriteria $ItemCodeCriteria "; Any ideas why it would be ignoring this one? Both others work fine! Thanks, Michael Link to comment https://forums.phpfreaks.com/topic/149929-solved-query-parameter-help/ Share on other sites More sharing options...
imperium2335 Posted March 18, 2009 Share Posted March 18, 2009 you are missing {}s from your nested if statements. Link to comment https://forums.phpfreaks.com/topic/149929-solved-query-parameter-help/#findComment-787408 Share on other sites More sharing options...
trq Posted March 18, 2009 Share Posted March 18, 2009 you are missing {}s from your nested if statements. Braces are not required in simple php blocks. To the op, have you tried echoing $sql? Also, what errors are you getting? Link to comment https://forums.phpfreaks.com/topic/149929-solved-query-parameter-help/#findComment-787412 Share on other sites More sharing options...
mboucher Posted March 18, 2009 Author Share Posted March 18, 2009 Hi, Where would I put the echo $sql? There are no errors, it just returns ALL results instead of applying the criteria. Thanks, you are missing {}s from your nested if statements. Braces are not required in simple php blocks. To the op, have you tried echoing $sql? Also, what errors are you getting? Link to comment https://forums.phpfreaks.com/topic/149929-solved-query-parameter-help/#findComment-787416 Share on other sites More sharing options...
mboucher Posted March 18, 2009 Author Share Posted March 18, 2009 I've done the echo and it appears the input in the itemcode box isn't getting through to the query for some reason... select i.ItemCode, i.ItemName, i.OnHand, i.IsCommited, i.OnOrder, g.itmsgrpnam as GroupName from OITM i, OITB g where i.itmsgrpcod = g.itmsgrpcod and i.itemname like '%%' and i.ItemCode like '%%' you are missing {}s from your nested if statements. Braces are not required in simple php blocks. To the op, have you tried echoing $sql? Also, what errors are you getting? Link to comment https://forums.phpfreaks.com/topic/149929-solved-query-parameter-help/#findComment-787418 Share on other sites More sharing options...
mboucher Posted March 18, 2009 Author Share Posted March 18, 2009 I've found it, little case sensitivity problem! <input class=input size=15 align=middle type=text name=Itemcode value=$ItemCode> Should have been <input class=input size=15 align=middle type=text name=ItemCode value=$ItemCode> Thanks for your help! I've done the echo and it appears the input in the itemcode box isn't getting through to the query for some reason... select i.ItemCode, i.ItemName, i.OnHand, i.IsCommited, i.OnOrder, g.itmsgrpnam as GroupName from OITM i, OITB g where i.itmsgrpcod = g.itmsgrpcod and i.itemname like '%%' and i.ItemCode like '%%' you are missing {}s from your nested if statements. Braces are not required in simple php blocks. To the op, have you tried echoing $sql? Also, what errors are you getting? Link to comment https://forums.phpfreaks.com/topic/149929-solved-query-parameter-help/#findComment-787419 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.