Jump to content

Sql hellp need please


rastaman46

Recommended Posts

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

Link to comment
Share on other sites

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')

 

 

Link to comment
Share on other sites

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; 
}

Link to comment
Share on other sites

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 == "") 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.