I have a field where i know for sure the entries would be something like Edward, John, Jacob in a input field.
Now, i am trying to insert a new row for each of the people. I am doing this:
$person = mysql_real_escape_string($_POST['person']);
foreach($person_array as $value)
{
$insert = "INSERT INTO people (Person)
VALUES ('".$value."')";
$query = mysql_query($insert) or die ("Error: ".mysql_error());
}
Using the above query i am unable to insert into the table. What am i doing wrong?
If $_POST[‘person’] is indeed a value as such : “John, Edward, Jacob” then it’s just a string; you’ll need to convert it into an array with explode. Also, it should be $_POST not $POST.
Then you can run your foreach function.