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 7839615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:29:41+00:00 2026-06-02T15:29:41+00:00

I have faced a problem whenever exporting a CSV file with PHP. I have

  • 0

I have faced a problem whenever exporting a CSV file with PHP. I have a MYSQL query like

SELECT `interest_id`,`interest_name`,`interested_user_id` FROM `interest_list` WHERE `interest_name` LIKE '%fashion%'

But whenever I am trying to export one PHP file by making use of the above MySQL Query then my query is turning to

SELECT `interest_id`,`interest_name`,`interested_user_id` FROM `interest_list` WHERE `interest_name` LIKE 'úshion%'

SO that it returns no record.
Please tell me how can I solve the issue.
In the export file, I have written the code like:

header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');
$output = fopen('php://output', 'w');

//executed code

fputcsv($output, $blankArray);

Now please help me.

Actually, I make the query in one file like:

$search_sql = "SELECT `interest_id`,`interest_name`,`interested_user_id` FROM `interest_list`";

    if(isset($_REQUEST['search_user_btn'])){

        if($_REQUEST['search_intr'] != '')
$search_sql .= " WHERE `interest_name` LIKE '%".$_REQUEST['search_intr']."%' ";

    }                                                                                

Then in the same file I write like:

<a href="export.php?report=interest&qur=<?php echo $search_sql; ?>"><button>Export to CSV</button></a>

Finally In the export.php

header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=data.csv');
$output = fopen('php://output', 'w');

I am trying to get the value of $_REQUEST[‘qur’]. But unable to get the original value of $_REQUEST[‘qur’].

I think Now it is making sense.
Please help….

  • 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-06-02T15:29:47+00:00Added an answer on June 2, 2026 at 3:29 pm

    You can’t insert random strings in a URL because there’re some characters that have a special meaning in URLs. In PHP, you can encode the value of a URL parameter with rawurlencode(). Similarly, you can’t insert random characters in a HTML string for the same reason.

    <?php
    
    $url = 'export.php?report=interest&qur=' = rawurlencode($search_sql);
    
    ?>
    <a href="<?=htmlspecialchars($url)?>"><button>Export to CSV</button></a>
    

    Whatever, passing SQL in the URL is call to get hacked.

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

Sidebar

Related Questions

I have faced a problem in all of my php projects is that since
I’d like to consult about a problem I have faced. I've started working on
I have faced this problem quite often during the last couple of months, during
I have faced the same problem many times. The Same Problem was With This
I have a problem that I have not faced before: It seems that the
We have recently been faced with the problem of porting our C++ framework to
We've faced strange problem. We have log on service, that authenticates user, adds auth
I faced an interesting problem today. I have 4 strings which I need to
Today I faced a strange problem in C#. I have an ASP.NET page where
I have designed a custom section handler before but I'm faced with a problem

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.