Re: INSERT INTO using foreach

From: Date: Fri, 23 Jul 2004 21:01:56 +0000
Subject: Re: INSERT INTO using foreach
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-191691@lists.php.net to get a copy of this message
> 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 ($key) VALUES ('$value')"; you should also look read up on sql injection attacks.

« previous php.general (#191691) next »