GB_001 Posted December 24, 2007 Share Posted December 24, 2007 <?php mysql_connect("mysql.x10hosting.com", "gb_GB", "*****************") or die(mysql_error()); mysql_select_db("gb_USERInfo") or die(mysql_error()); session_start(); $var = $_POST['email'] ; $trim = trim($var); $earray = explode(" ",$trim); $result = mysql_query("SELECT * FROM Ysers WHERE firstname LIKE '%{$earray[0]}%'") or die(mysql_error()); while($row = mysql_fetch_array( $result )or die(mysql_error())) { echo $row['firstname']; echo"<br/>"; } My search script seems to bring up all names in the database, instead of what is searched for. Thankyou for your help. Quote Link to comment https://forums.phpfreaks.com/topic/83007-searching-problem/ Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 echo $earray[0] and see what it contains. Since it looks like you are exploding $var on a space which shouldn't exist since there should be no spaces on a email, I'm not sure what you are trying to achieve really. Did you mean do do this on a first name last name? Quote Link to comment https://forums.phpfreaks.com/topic/83007-searching-problem/#findComment-422187 Share on other sites More sharing options...
GB_001 Posted December 24, 2007 Author Share Posted December 24, 2007 No, I just switch to first name and last name to test it out Quote Link to comment https://forums.phpfreaks.com/topic/83007-searching-problem/#findComment-422195 Share on other sites More sharing options...
GB_001 Posted December 24, 2007 Author Share Posted December 24, 2007 I'm still having the same problem. I tried taking out explosion and using $trim. But it still showed every email in the database. So then I tried to echo trim, and it showed as blank. Quote Link to comment https://forums.phpfreaks.com/topic/83007-searching-problem/#findComment-422541 Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 Post your form. Quote Link to comment https://forums.phpfreaks.com/topic/83007-searching-problem/#findComment-422543 Share on other sites More sharing options...
janim Posted December 24, 2007 Share Posted December 24, 2007 yes you should post your form couse you use $_post['email'] while you searching in username Quote Link to comment https://forums.phpfreaks.com/topic/83007-searching-problem/#findComment-422555 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.