hyster Posted May 15, 2010 Share Posted May 15, 2010 im having trouble getting trim to work. on my search form, a scanner is used and for some reason its putting blank spaces in which are added to the search. where do i put the trim? ive tried a few different places but didnt work. Thanks for any help // Retrieve data from database $search=$_POST['search']; if ($search == '' || $search == ' '){ echo "Search Field is Empty - Please Input an Spl Number!"; echo "<body style='background:#FC0;'>"; die; } else{ // 1st query $sql="select * from spl WHERE spl1 LIKE TRIM('%$search%') LIMIT 1"; $result=mysql_query($sql) or die (mysql_error()); $rows=mysql_fetch_array($result); $passon=$rows['orsku']; //2nd $sql1="select * from dsgi WHERE reconsku LIKE '%$passon%'"; $result1=mysql_query($sql1) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/201831-trim-blank-spaces-in-search/ Share on other sites More sharing options...
themistral Posted May 15, 2010 Share Posted May 15, 2010 Try the first line as $search = trim($_POST['search']); and take out the TRIM in the sql. Link to comment https://forums.phpfreaks.com/topic/201831-trim-blank-spaces-in-search/#findComment-1058677 Share on other sites More sharing options...
hyster Posted May 17, 2010 Author Share Posted May 17, 2010 thanks themistral. it works a treat Link to comment https://forums.phpfreaks.com/topic/201831-trim-blank-spaces-in-search/#findComment-1059368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.