franknu Posted December 20, 2006 Share Posted December 20, 2006 ok, i want that when the user select type and make and there is a Categories for type and make to display what is on the database the problem is that i am getting No Results found any idea whyhere is my code[code=php:0]$query = "SELECT * ". "FROM `business_info` ". "WHERE `make`=='make' ". "AND `type`=='type'". ((!empty($Categories)) ? " AND `Categories` LIKE '%".$Categories."%'":''); $result = mysql_query($query) or die (mysql_error()); $num_result = mysql_num_rows($result); echo "<table>";if($num_result <= 0){ echo("No Results found."); exit;[/code] Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/ Share on other sites More sharing options...
Orio Posted December 20, 2006 Share Posted December 20, 2006 Dont use ==, you only need one =[code]`make`=='make' //wrong`make`='make' //correct[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145160 Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 i did it with only one and i was still getting No results found i have a make, type and categories on the rowthis one works[code=php:0]$query = "SELECT * FROM `business_info` WHERE Categories LIKE '%".$Categories."%'";[/code] but it only search for categories it doen't mind what is on type and makeplease help Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145181 Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 [code=php:0]$query = "SELECT * ". "FROM `business_info` ". "WHERE `make`='make' ". "AND `type`='type'". ((!empty($Categories)) ? " AND `Categories` LIKE '%".$Categories."%'":''); [/code] Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145186 Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 thi is are new changes[code=php:0]$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type'" AND Categories LIKE '%".$Categories."%'";[/code]but this is the error message that i got Parse error: syntax error, unexpected T_STRING in /home/townsfin/public_html/business_display.php on line 45 Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145223 Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 Try this$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type'" AND Categories LIKE \"%.$Categories.%\" "; Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145225 Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 ok i made new changes and this is the new: code:[code=php:0]$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type' AND Categories LIKE '%".$Categories."%'";[/code]message, No Results found Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145227 Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 i tried the last code but no luckNo Results found Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145233 Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 You will always have to use the backslashes when using wildcards and or variables$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type'" AND Categories LIKE \"%$Categories%\" ";Try removing the fullstops Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145239 Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 this is what i tried [code=php:0]$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type' AND Categories LIKE \"%.$Categories.%\" ";[/code]displayedNo Results foun Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145249 Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 also shouldnt make and type be put into variables???$query = "SELECT * FROM business_info WHERE make=\"$make\" AND type=\"$type\" AND Categories LIKE \"%$Categories%\" "; cos otherwise you are searching for something that has make stored in the make field??unless you want$query = "SELECT make, type FROM business_info WHERE Categories LIKE \"%$Categories%\" "; Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145251 Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 take out the fullstops!!! [color=red].$Categories.[/color] becomes [color=red]$Categories[/color] no fullstops Link to comment https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.