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

  • Home
  • SEARCH
  • 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 8844621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:32:01+00:00 2026-06-14T11:32:01+00:00

I am trying to get the values from a php file. I have a

  • 0

I am trying to get the values from a php file.

I have a java file like this

ArrayList<NameValuePair> al = new ArrayList<NameValuePair>();

for (int i = 0; i < name.size(); i++) 
{
    al.add(new BasicNameValuePair("names["+i+"]",String.valueOf(name.get(i))));

    System.out.println("arr is " +String.valueOf(name.get(i)+ "arrrr"+name.get(i)));
}

Here, name is an ArrayList.

Now I want that name ArrayList to be sent to php and loop that array and insert into database

this is my php file

$con = mysql_connect("localhost","aaa","aa");
mysql_select_db("aa", $con);

if (!$con)
{
    die('Could not connect: ' . mysql_error());
}

$arr[] = $_POST['names[]'];

foreach ($arr as $key) 
{
    $query="insert into Orders1(names) values('$key')";
    mysql_query($query);
}

it’s inserting "" (empty) value in database please help me.

  • 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-14T11:32:02+00:00Added an answer on June 14, 2026 at 11:32 am

    edit: and now you’ve deleted your php code, so the following won’t make much sense…


    If you’re using array-based field names in your html form, e.g.

    then the [] do NOT appear in the $_POST array when the form’s submitted. Instead, $_POST['foo'] becomes a sub-array of the various values entered into those form fields.

    That means

    $arr[] = $_POST['names[]'];
    

    is almost certainly an undefined array key, returning a NULL, which you then append to the $arr array. You loop over $arr and insert the values, but insert only that null.

    Try, simply:

    foreach($_POST['names'] as $val) {
      $v = mysql_real_escape_string($val);
      $sql = "ISNERT INTO .... VALUES ('$v');
    }
    

    note the use of the escape function. Your code is highly vulnerable to SQL injection attacks and would leave your server open to a total remote compromise.

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

Sidebar

Related Questions

I am trying to get double values from file using fscanf function. I am
I am trying to get coordinates from GPS (this actually gives the values for
i am trying to send email from php i have one php file with
I am trying to cache something. In my core.php config file, I have this:
I'm trying to get values from nsdata class and doesn't work. here is my
I am trying to get values from a data set. My function has to
I am trying to get the values from an HTML table row. When I
I'm trying to get the values from a pointer to a float array, but
I am trying to get the privacy values (from privacy table) for photos that
So I am trying to get the e_values from the file

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.