Re: INSERT INTO using foreach

From: Date: Mon, 26 Jul 2004 01:04:37 +0000
Subject: Re: INSERT INTO using foreach
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-191854@lists.php.net to get a copy of this message
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 the script execution.
} else{ $sql = "INSERT INTO registration ('$key')
      VALUES ('$value')";
$result = mssql_query($sql); } } I keep getting an invalid object 'registration' error. However registration is the name of the table. I'm guessing it's someplace else in the statement that I'm messing up on.


« previous php.general (#191854) next »