rastaman46 Posted April 10, 2012 Share Posted April 10, 2012 Hello again here is my prob im trying to run in my search php membername is column with all members in it rastaman46 is one of the members But im cant get it search by name Please help SELECT * FROM tsue_members WHERE upper(membername) LIKE %Rastaman46% but keep geting error MySQL server version for the right syntax to use near '%Rastaman46% LIMIT 0, 30' at line 1 Quote Link to comment Share on other sites More sharing options...
DavidAM Posted April 10, 2012 Share Posted April 10, 2012 First, you need to put quotes around the value you are searching for: SELECT * FROM tsue_members WHERE upper(membername) LIKE '%Rastaman46%' But note that you are using the UPPER() function on the column which means you are comparing "RASTAMAN46" (from the column) to 'Rastaman46'. I'm not sure if the that will work even if you are using a Case Insensitive character set on the table. Also, if you are looking for an EXACT match, you don't want to use LIKE. SELECT * FROM tsue_members WHERE upper(membername) = UPPER('Rastaman46') Quote Link to comment Share on other sites More sharing options...
rastaman46 Posted April 10, 2012 Author Share Posted April 10, 2012 Thanks works now query but my form dont post anything in just refrech page ??? form is <form name="search" method="post"> Search for: <input class="rasta_text" type= "text" name="find" /> in <Select class="darozas" NAME="field"> <Option VALUE="name">Torrent name</option> <Option VALUE="membername">Username</option> <Option VALUE="info">Paskey</option> </Select> <input type="hidden" name="searching" value="yes" /> <input class="submit" type="submit" name="search" value="Search" /> </form> //This is only displayed if they have submitted the form $searching = ''; if ($searching =="yes") { $nervai = "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error $find = ''; if ($find == "") { $nervai = "<p>You forgot to enter a search term"; exit; } // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $nervai = ''; $run = $TSUE['TSUE_Database']->query("SELECT t.tid, t.info_hash, t.name, t.description, t.cid, t.size, t.added, t.leechers, t.seeders, t.times_completed, t.owner, t.options, t.nfo, t.sticky, t.flags, t.mtime, t.ctime, t.download_multiplier, t.upload_multiplier, t.external, t.tags, r.cname, u.membername, m.groupname, m.groupstyle FROM tsue_membergroups AS m Inner Join tsue_members AS u ON u.membergroupid = m.membergroupid Inner Join tsue_torrents AS t ON t.owner = u.memberid Inner Join tsue_torrents_categories AS r ON t.cid = r.cid WHERE upper($field) LIKE'%$find%'"); $week_yra = mysqli_num_rows($run); if($run){ if(mysqli_num_rows($run) == 0){ $nervai = '<div class="error" id="show_error">Nothing found</div>'; } else { while ($row = mysqli_fetch_array($run)) { $savaites = ''; $name = $row['name']; $cat = $row['cid']; $data = date('Y-m-d H:i:s',$row['added']); $baigtas = $row['times_completed']; $uploader = str_replace('{membername}', $row['membername'], $row['groupstyle']); $description= $row['description']; $dydis = size_hum_read($row['size']); $leechers= $row['leechers']; $owner= $row['owner']; $nunx= $row['tid']; $seeders= $row['seeders']; $free = ""; if ($row['download_multiplier'] < 1){ $free = '<img title="'.get_phrase('torrent_free').'" src="'.$baseurl.'/styles/'.$theme.'/torrents/torrent_free.png"/>'; } $freeif = ''; if ($row['download_multiplier'] > 1){ $freeif = '<img title="'.get_phrase('torrent_download_multiplier').':'.$row['download_multiplier'].'" src="'.$baseurl.'/styles/'.$theme.'/torrents/torrent_free.png"/>'; } $double = ""; if ($row['upload_multiplier'] > 1){ $double = '<img title="'.get_phrase('torrent_upload_multiplier').':'.$row['upload_multiplier'].'" src="'.$baseurl.'/styles/'.$theme.'/torrents/torrent_multiple_upload.png"/>'; } $stiky = ""; if ($row['sticky'] > 0){ $stiky = '<img title="'.get_phrase('sticky_torrent').'" src="'.$baseurl.'/styles/'.$theme.'/torrents/sticky.png"/>'; } $torrent_images = ''; $torrent_images = $free.$freeif.$double.$stiky; $test = $TSUE['TSUE_Database']->query("select * from tsue_attachments where tsue_attachments.content_id = $nunx and content_type = 'torrent_images'"); $filename = ''; if(mysqli_num_rows($test) == 0){ $filename = "noposter.png"; }else{ while ($row = mysqli_fetch_array($test)) { $filename = $row ['filename']; } } eval("\$jamam = \"".$TSUE['TSUE_Template']->LoadTemplate('rasta_export')."\";"); $nervai .= $jamam; } } } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysqli_num_rows($run); if ($anymatches == 0) { $nervai = "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for $nervai = "<b>Searched For:</b> " .$find; } Quote Link to comment Share on other sites More sharing options...
DavidAM Posted April 10, 2012 Share Posted April 10, 2012 You are not actually collecting the data from the form: //This is only displayed if they have submitted the form $searching = (isset($_POST['searching']) ? $_POST['searching'] : ''); if ($searching =="yes") { $nervai = "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error $find = (isset($_POST['find']) ? $_POST['find'] : ''); if ($find == "") Quote Link to comment Share on other sites More sharing options...
rastaman46 Posted April 10, 2012 Author Share Posted April 10, 2012 LOVE you m8 thanks sorted Big big thanks m8 Quote Link to comment Share on other sites More sharing options...
fenway Posted April 14, 2012 Share Posted April 14, 2012 FYI, UPPER() still won't guarantee a case-sensitive match. Quote Link to comment 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.