Re: Multiple INSERT using for() into a MySQL database

From: Date: Fri, 12 Oct 2001 05:36:58 +0000
Subject: Re: Multiple INSERT using for() into a MySQL database
Groups: php.db 
Request: Send a blank email to php-db+get-13286@lists.php.net to get a copy of this message
Hi, if you use for the syntaxis is for (expr1; expr2; expr3) { } Notice that there is ";" instead of ",". Try this for($i=1; $i<12; $i++) { $query2 = "INSERT INTO ausPermisions(permView,permEdit,permAdd,permDelete,userID,modID) VALUES('N','N','N','N','$id','$i')"; $result2 = mysql_query($query2) or die("doh!"); } Dobromir Velev -----Original Message----- From: Peter Brown <peter@outputdsj.com.au> To: php-db@lists.php.net <php-db@lists.php.net> Date: Friday, October 12, 2001 6:51 AM Subject: [PHP-DB] Multiple INSERT using for() into a MySQL database >Hi > >Novice question time. > >I am attempting to do a multiple INSERT by creating 11 records in a MySQL >database using a for() control structure. > >The code snippet is as follows > > for($i=1, $i<12, $i=$i+1) {; > $query2 = "INSERT INTO >ausPermisions(permView,permEdit,permAdd,permDelete,userID,modID) >VALUES('N','N','N','N','$id','$i')"; > $result2 = mysql_query($query2) or die("doh!"); > }; > >the $id is already defined and yes the modID is supposed to correspond to >the value of $i > >I keep on getting the ... parse error, expecting `';'' ... error > >Anyhow, I am a beginner with PHP and was wondering wondering why \this >doesnt work. If I'm not doing this the right way any advice etc would be >great. > >Thanks >Peter > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net >For additional commands, e-mail: php-db-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#13286) next »