Alex Hogan wrote:
Hi All,
I have a form with several values to insert.
I thought that I remember a thread that discussed using a loop to insert
$_POSTed values.
I am trying;
foreach($_POST as $key = $value){
if($key == 'Submit'){
exit;
i think you want break; or continue; here, exit; ends
foreach($_POST as $key = $value){
if($key == 'Submit'){
exit;
}
else{
$sql = INSERT INTO registration ('$key')
VALUES ('$value');
$result = mssql_query($sql);
}
}
not sure if wrapping columns names in single quotes is valid mssql, try:
$sql = INSERT INTO registration
It may be a matter of opinion, but i beleive this is a poor method of
doing what your doing. I would get my values thru $_REQUEST and use
addslashes to escape what needs to be escaped, and i would write my
SQL query with full column listing and string values in quotes. eg..
INSERT INTO table
3 matches
Mail list logo