Verbat Posted January 24, 2008 Share Posted January 24, 2008 This is the code i have - $query8 = sprintf("SELECT * from test WHERE username LIKE '%a%'",$db_connect); $result8 = dbquery($query8); while ($rpw = mysql_fetch_assoc($result8) ) { $username = $rpw['username']; echo "$username"; } I tryed to work it with some VAR info but it didnt work so i made a simple search code like this and for some reason it doesnt work. What am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/ Share on other sites More sharing options...
trq Posted January 24, 2008 Share Posted January 24, 2008 What is your expected results? Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447729 Share on other sites More sharing options...
rajivgonsalves Posted January 24, 2008 Share Posted January 24, 2008 well what is dbquery did you write that function... for a matter of simplicity it should of been $query8 = "SELECT * from test WHERE username LIKE '%a%'"; $result8 = mysql_query($query8); while ($rpw = mysql_fetch_assoc($result8) ) { $username = $rpw['username']; echo "$username"; } Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447730 Share on other sites More sharing options...
Verbat Posted January 24, 2008 Author Share Posted January 24, 2008 rajivgonsalves - I tryed with mysql_query aswell and still it gives and error thorpe - all usernames with a inside. Just a simple search i made to see if it's working. Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447732 Share on other sites More sharing options...
rajivgonsalves Posted January 24, 2008 Share Posted January 24, 2008 this $result8 = mysql_query($query8); change it too $result8 = mysql_query($query8) or die("Cannot execute:".mysql_error()); and tell me if you get any errors Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447736 Share on other sites More sharing options...
Verbat Posted January 24, 2008 Author Share Posted January 24, 2008 This is the error i get - Warning: sprintf() [function.sprintf]: Too few arguments in test.php on line 27 Cannot execute:Query was empty Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447741 Share on other sites More sharing options...
trq Posted January 24, 2008 Share Posted January 24, 2008 As rajivgonsalves pointed out, you do not need sprintf at all. Read the replies to your questions. Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447743 Share on other sites More sharing options...
Verbat Posted January 24, 2008 Author Share Posted January 24, 2008 As rajivgonsalves pointed out, you do not need sprintf at all. Read the replies to your questions. Ohhh, i missed that part. Sorry. Thanks alot for the help. Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.