Re: [PHP] INSERT INTO using foreach

2004-07-25 Thread Marek Kilimajer
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

Re: [PHP] INSERT INTO using foreach

2004-07-23 Thread Jason Davidson
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 (col

Re: [PHP] INSERT INTO using foreach

2004-07-23 Thread Matt M.
> 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