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

The Archive Base Latest Questions

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

Hello Sir i am pass array list through url android to php my arraylistvalues[x,y.z,….]

  • 0

Hello Sir i am pass array list through url android to php
my arraylistvalues[x,y.z,....] this all values inserted into single column(menuname) in test table to mysql using php

i tried this

$a=$_POST['menuname'];
mysql_connect("localhost","root","MobixMySQL");
mysql_select_db("test");
foreach($a as $value)
{
  mysql_query("INSERT INTO test (menuname) VALUES $value)")or
  die ('unable'.mysql_error());
  echo "Inserted";
}

i try above php it shows error valild argument in foreach please tell me how to solve ..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-01T11:06:40+00:00Added an answer on June 1, 2026 at 11:06 am

    $a might not be an array, and as such, foreach throws error as it expects its argument to be an array.

    You can do a var_dump to see what $_POST['menuname'] really is.

    Also, use mysql_real_escape_string to escape things before you insert to db

    mysql_query("INSERT INTO test (menuname) VALUES ('" . mysql_real_escape_string($value) . "')");
    

    https://www.php.net/mysql_real_escape_string

    Or better yet, use pdo http://sg.php.net/pdo

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

Sidebar

Related Questions

Hello sir i send the arraylist through url pass from android to php all
Hello Sir i want send list of data to php server i use following
Hello guys I need to pass a string array over to a setter that
Hello All I am trying to flatten a list in Ocaml. I am a
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello! I'm not even sure if this is possible, but hopefully it is in
$(.menu-container).animate({top:25px}); $(.menu-container).animate({top:-900px}); $(.windows-container).animate({top:-730px}); hello sir.. i got a problem on queue in jquery.. what
Hello everyone i am trying to format the input number range with php number_format
hello friends i am trying to get a list of user id and want
Hello Guys I am trying to figure out why i am gettings this error

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.