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? Quote 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? Quote 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"; } Quote 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. Quote 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 Quote 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 Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/87538-solved-where-like-problem/#findComment-447746 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.