divadiva Posted June 12, 2008 Share Posted June 12, 2008 Experts I am going to ask the same question I asked yesterdat but this time I will be more precise.I did tried some debugging on myside,but I would appreciate your expert advice. My system has on of the field named "Word"(basically a textbox).In this textbox you can enter a number or word and hit search.If there is any data present in database it will return the data.But the problem is that when I hit search I get an empty table. I was debugging and found that somehow the system is duplicating the values I enter.Supposingly I enter 'a' in word column I get 'aa' in return. Below is the code: <% if ($swords){ //print_r($_POST); //print_r($_GET); print $swords; print $swords; $fstring .= " AND ( `description` REGEXP '$swords' OR `configuration` REGEXP '$swords' OR `software` REGEXP '$swords' OR `hardware` REGEXP '$swords' OR `model` REGEXP '$swords' OR `manufacturers` REGEXP '$swords' OR `process` REGEXP '$swords' OR `inventory_id` REGEXP '$swords' OR `serial_number` REGEXP '$swords' OR `tool_id` REGEXP '$swords' )"; } else { print 'N/A'; Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/ Share on other sites More sharing options...
conker87 Posted June 12, 2008 Share Posted June 12, 2008 Try replacing all '$sword' with '%$sword%' Wait, you are printing it twice you know... Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563946 Share on other sites More sharing options...
divadiva Posted June 12, 2008 Author Share Posted June 12, 2008 $print sword at the top is for check .I tried what you have sugegsted but didnt work. I have another file "edit inventory" It uses same piece of code and works there. Please help me on this.I will appreciate your suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563958 Share on other sites More sharing options...
Buddski Posted June 12, 2008 Share Posted June 12, 2008 conker is right if you have print $swords; print $swords; and 'a' is stored in $swords you are going to get 'aa' as output.. Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563965 Share on other sites More sharing options...
divadiva Posted June 12, 2008 Author Share Posted June 12, 2008 Thanks for replying. I commented "print $swords;" .But still it is not showing any result. Regards Diva Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563972 Share on other sites More sharing options...
conker87 Posted June 12, 2008 Share Posted June 12, 2008 Try doing what I said anyway: Replace all '$sword' with '%$sword%' Also, I've never heard of the REGEXP function in SQL. Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563976 Share on other sites More sharing options...
divadiva Posted June 12, 2008 Author Share Posted June 12, 2008 Thanks once againfor replying. I will try that. Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563979 Share on other sites More sharing options...
divadiva Posted June 12, 2008 Author Share Posted June 12, 2008 I tried that doesnt do any good . Actuallt I have one more file "Edit Inventory" which uses same logic "WORD" works fine.But somehow this doesnt works. Interestingly ,in the other file if I type print$swords it returns one alphabet whereas the file I am trying to debug returns duplicate values.Thats why I mentioned this point in one of my previous posts. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563985 Share on other sites More sharing options...
GingerRobot Posted June 12, 2008 Share Posted June 12, 2008 Also, I've never heard of the REGEXP function in SQL. http://dev.mysql.com/doc/refman/5.0/en/regexp.html Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-563995 Share on other sites More sharing options...
conker87 Posted June 12, 2008 Share Posted June 12, 2008 Also, I've never heard of the REGEXP function in SQL. http://dev.mysql.com/doc/refman/5.0/en/regexp.html Convenient! Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-564014 Share on other sites More sharing options...
divadiva Posted June 12, 2008 Author Share Posted June 12, 2008 I have fixed .Issue was SQL was not right.Parenthesis ")" were missing.Thanks all for the suggestions. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/109907-debugging-php-code/#findComment-564263 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.