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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:00:31+00:00 2026-05-26T17:00:31+00:00

Here is the original code: if (($handle = fopen($source_file, r)) !== FALSE) { $columns

  • 0

Here is the original code:

       if (($handle = fopen($source_file, "r")) !== FALSE) {
    $columns = fgetcsv($handle, $max_line_length, ",");
    foreach ($columns as &$column) {
        $column = str_replace(".","",$column);
    }
    while (($data = fgetcsv($handle, $max_line_length, ",")) !== FALSE) {
        while(count($data) < count($columns)) {
            array_push($data, NULL);
        }
        $c = count($data);
        for($i = 0; $i < $c; $i++) {
            $data[$i] = "'{$data[$i]}'";
        }

        $sql[] = '(' . implode(',', $data) . ", '" . $_POST['custgroup'] . "'," . $_POST['user_id'] . ')';
    }


$query = "INSERT INTO $target_table (" . implode(',', $columns) . 
      ',custgroup,user_id) VALUES ' . implode(',', $sql);


    //mysql_query($query) or trigger_error(mysql_error());
    echo $query;
    fclose($handle);
}

But once I added mysql_real_escape_string:

   $query = "INSERT INTO $target_table (" . implode(',',array_map('mysql_real_escape_string', $columns)) . 
          ',custgroup,user_id) VALUES ' . implode(',',array_map('mysql_real_escape_string', $sql));

The query will become :

INSERT INTO UserAddedRecord (lastname,firstname,ceLL,fax,email,code,custgroup,user_id) VALUES (\'Last\',\'First\',\'01122331\',\'\',\'abc@hotmail.com\',\'12345\', \'\',17)

I checked my php.ini and get_magic_quotes_gpc(),magic quote is disabled.

magic_quotes_gpc = Off

magic_quotes_runtime = Off

magic_quotes_sybase = Off

What should be the problem?or I should just apply stripslashes()?But I assume it will be used only when magic quote is enabled.

  • 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-26T17:00:31+00:00Added an answer on May 26, 2026 at 5:00 pm

    You should to something along the lines of:

    • use mysql_real_escape_string on all string values
    • cast all the interters to (int)
    • after that apply the surrounding single quotes ( ‘ )

    The point of mysql_real_escape_string is to escape the special chars within your test content so using stripslashes would take that away.

    Another way to solve that is to look into preparedStatements where you don’t need to to client side esacping.

    Just remember that the whole point of doing this is to prevent SQL-Injection and act accordingly 🙂

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

Sidebar

Related Questions

here is the original code: public static int getInt () { Scanner in =
Refer original post here for a reference to the original issue. What plugin should
So here is the original query SELECT SUM(PickQty), SUM(ReqQty), AssignmentID, StopID FROM PickRequest GROUP
Let's say I have some original text: here is some text that has a
Ok, here was my original question; Table one contains ID|Name 1 Mary 2 John
This question is sort of a follow-up to my original question here . Let's
I'm trying to parallelize a convolution function in C. Here's the original function which
My original question can be found here , for which I've gotten some great
Here's a perfect example of the problem: Classifier gem breaks Rails . ** Original
Basically I need to reset Identity Increment for all tables to its original. Here

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.