RE: [PHP] probably stupid, but...

From: Date: Fri, 12 Nov 2004 20:32:08 +0000
Subject: RE: [PHP] probably stupid, but...
Groups: php.general 
Request: Send a blank email to php-general+get-201864@lists.php.net to get a copy of this message
Robert Sossomon <mailto:robert_sossomon@ncsu.edu> on Friday, November 12, 2004 12:09 PM said: > I have a form that sends 20 rows of data into a script, instead of > having to write 20 separate add functions, I wrote this piece of > code... you've actually got quite a few mistakes. > if ($_POST[book_title_$i]' != "") notice ----------------------^ there is an extra '. the line should really look like: if (!empty($_POST['book_title_'.$i]) { ... > { > INSERT INTO curriculum VALUES > ('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades _$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_tit le_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_ $i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_ $i]','$_POST[pages_$i]','$_POST[c_kit_$i]'); and then here you don't even assign that sql statement to anything. PHP doesn't know what to do with it. also you need to wrap your array values in { } when an array is referenced within a string. i.e. // normal $value = $_GET['something']; // with { } $value = "Here is some data: {$_GET['something']}"; hth, chris.

« previous php.general (#201864) next »