Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:51:14+00:00 2026-05-27T04:51:14+00:00

How to do absolute MySQL query match. Since I seem getting collision if a

  • 0

How to do absolute MySQL query match. Since I seem getting collision if a user is trying to call a url or a file via short link domain.ltd/NGV which collides with domain.ltd/ngv forcing the fetch script to pull /NGV file not /ngv

Here is the code which does the MySQL selections also the htaccess bit is provided

 $tag = $_REQUEST['rid'];

 $q = mysql_query("SELECT * FROM `media` WHERE `qp_tag` = '".mysql_escape_string($tag)."' LIMIT 1");

 $r = mysql_fetch_row($q);

 if(!empty($r)) {

     $f = stripslashes($r['file']);
     $t = stripslashes($r['type']);

     $c = file_get_contents($f);

     $api_html = <<<API_HTML_VIEW
     $c
             API_HTML_VIEW;

     echo $api_html;

 } else {

     $api_html = <<<API_HTML_VIEW
     We are sorry but we cannot find requested resource :(
             API_HTML_VIEW;

     echo $api_html;

 }

.htaccess code bit

RewriteRule ^([a-zA-Z0-9-]+)/?$ api.php?rid=$1 [L,QSA]

and here is the last bit of code to generate the actual short links which also may be the problem since i am not sure whats kicking the thing back at the present moment

function qp_tag() {

     $file_tag = $_FILES['file']['name'];
     $file_uni = uniqid();
     $short = strtolower(substr(base64_encode(crc32($file_tag)), 0, 3));  

     return $short;

}

Edited: The system works now the only problem is that it lags allot on selecting file if its a file

 $f = $r['file'];
 $t = $r['type'];
 $s = $r['size'];
 $n = $r['name'];

 header("Pragma: public"); // required
 header("Expires: 0");
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header("Cache-Control: private",false); // required for certain browsers
 header("Content-Type: ".$t."");
 header("Content-Disposition:attachment;filename=".$n."");
 header("Content-Length: ".$s);
 ob_clean(); 
 flush();

 $fp = fopen($f, "r"); 
 while (!feof($fp))
     {
         echo fread($fp, 65536); 
         flush(); // this is essential for large downloads
     }  
 fclose($fp);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:51:15+00:00Added an answer on May 27, 2026 at 4:51 am

    If I understand you correctly, you want to use the BINARY operator for case-sensitive matching:

    $q = mysql_query("SELECT * FROM `media` WHERE BINARY `qp_tag` = '".mysql_escape_string($tag)."' LIMIT 1");
    

    This is the same as your query above except I’ve inserted the word BINARY in the comparison.

    Note that it’s possible you won’t be able to take full advantage of the any indexes on the comparison column if you do this. That may not be an issue at all for you, but take it into consideration if your table has a lot of rows in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to import json data to mysql.My json file nearly 3.7Mb and have
I am trying to store facebook user's data array in mysql. I have used
Absolute beginner question: I have a template file index.html that looks like this: ...
Given an absolute URI/URL, I want to get a URI/URL which doesn't contain the
I wanted to make mysql dump files using a batch file and an app
I am trying to figure why I am getting this error. **Warning: require_once(\C\wamp\www\PHP with
I'm trying to write a PHP script to backup a MySQL database: if (
I'm trying to insert values from a form and insert it onto a MySQL
I am a beginner at using mysql and I am trying to learn the
I am trying to retrive data to my SL application from PHP, MySQL service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.