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
$amight not be an array, and as such,foreachthrows error as it expects its argument to be an array.You can do a
var_dumpto see what$_POST['menuname']really is.Also, use
mysql_real_escape_stringto escape things before you insert to dbhttps://www.php.net/mysql_real_escape_string
Or better yet, use
pdohttp://sg.php.net/pdo