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

2004-11-13 Thread Curt Zirzow
* Thus wrote -{ Rene Brehmer }-:
 At 21:32 12-11-2004, Chris W. Parker wrote:
 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']};
 
 Is that actually in the manual ??? If it is, where ?

Yeah, its defined in the array section where it defines the proper
way to access array's (Array do's and dont's)

  http://php.net/manual/en/language.types.array.php


Curt
-- 
Quoth the Raven, Nevermore.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2004-11-13 Thread -{ Rene Brehmer }-
At 16:28 13-11-2004, Curt Zirzow wrote:
* Thus wrote -{ Rene Brehmer }-:
 At 21:32 12-11-2004, Chris W. Parker wrote:
 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']};

 Is that actually in the manual ??? If it is, where ?
Yeah, its defined in the array section where it defines the proper
way to access array's (Array do's and dont's)
  http://php.net/manual/en/language.types.array.php
Thanks alot :) ... Could've sworn I read everything in the syntax section 
... but must've overlooked that somehow :-/

Rene
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] probably stupid, but...

2004-11-12 Thread Robert Sossomon
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...

$i=1;
while ($i20)
{
 if ($_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_title_$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]');

  $message .= The entry  $i was entered
;
 $i++;
 }
 else
{  $i++; }
}
But I get THIS error in the log:
 [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected  T_VARIABLE, 
expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php on line 19

-
How can I go about iterating through the script?  or do I just need to write 20 
if/else statements and separate inserts?

Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-11-12 Thread Jay Blanchard
[snip]
$i=1;
while ($i20)
{
  if ($_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]');

   $message .= The entry  $i was entered;
  $i++;
  }
  else
{  $i++; }
}

But I get THIS error in the log:
  [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected
T_VARIABLE, 
expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php
on line 19
[/snip]

Where is line 19? Is this it?

if ($_POST[book_title_$i]' != )

If so, remove the apostrophe after the ]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2004-11-12 Thread Danny Brow
On Fri, 2004-11-12 at 15:08 -0500, Robert Sossomon wrote:
 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...
 
 $i=1;
 while ($i20)
 {
   if ($_POST[book_title_$i]' != ) 
// One problem maybe the quote you have at the end of your $_POST
request.

   {
INSERT INTO `curriculum` VALUES 

// You could probably simplify this with a while or for loop. But I'm no
PHP expert. Perhaps you could use an array to clean this up.

 ('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_title_$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]');
 
$message .= The entry  $i was entered
 ;
   $i++;
   }
   else
 {  $i++; }
 }
 

Sorry if I missed anything else :-

Dan.


 But I get THIS error in the log:
   [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected  
 T_VARIABLE, 
 expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php on 
 line 19
 
 -
 
 How can I go about iterating through the script?  or do I just need to write 
 20 
 if/else statements and separate inserts?
 
 Thanks,
 Robert
 
 -- 
 Robert Sossomon, Business and Technology Application Technician
 4-H Youth Development Department
 200 Ricks Hall, Campus Box 7606
 N.C. State University
 Raleigh NC 27695-7606
 Phone: 919/515-8474
 Fax:   919/515-7812
 [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2004-11-12 Thread Robert Sossomon
Jay Blanchard is quoted as saying on 11/12/2004 3:28 PM:
 [snip]
Did that and it fixed only that piece (saw it right after I sent the email out 
to the group).  I am thinking that it is still somewhat of the iterations that 
are causing problems.  I am waiting on the server guy to get back with me as to 
what the new error message looks like.

Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-11-12 Thread Chris W. Parker
Robert Sossomon mailto:[EMAIL PROTECTED]
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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2004-11-12 Thread Jay Blanchard
[snip]
Did that and it fixed only that piece (saw it right after I sent the
email out 
to the group).  I am thinking that it is still somewhat of the
iterations that 
are causing problems.  I am waiting on the server guy to get back with
me as to 
what the new error message looks like.
[/snip]

Have you echo'd the query out to see what it looks like?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2004-11-12 Thread Danny Brow
On Fri, 2004-11-12 at 14:35 -0600, Jay Blanchard wrote:
 [snip]
 Did that and it fixed only that piece (saw it right after I sent the
 email out 
 to the group).  I am thinking that it is still somewhat of the
 iterations that 
 are causing problems.  I am waiting on the server guy to get back with
 me as to 
 what the new error message looks like.
 [/snip]
 
 Have you echo'd the query out to see what it looks like?
 

It's probably a good idea to get the part of a reply that tells everyone
who your replying too. Not sure if it was me or Chris P.

Chris has a way better answer then I. So I assume your replying to mine.

Dan.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2004-11-12 Thread -{ Rene Brehmer }-
At 21:32 12-11-2004, Chris W. Parker wrote:
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']};
Is that actually in the manual ??? If it is, where ?
I've been learning PHP for a little over 2 years now, and I've kept jumping 
in and out of strings because I couldn't figure out how to make the darn 
thing replace array values within it.

The syntax section does not mention this that I've been able to find, nor 
does the variable section, and if it's in the array section then it's very 
well buried. I seriously think the basic syntax section needs to cover a 
bit more ground ... it would also solve our problem with recurring 
questions about very basic things.

I'm not saying that the manual should be a complete teach-it-yourself 
guide, but basic stuff that you need to use like all the time ought to be 
in there.

Rene
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-11-12 Thread Chris W. Parker
-{ Rene Brehmer }- mailto:[EMAIL PROTECTED]
on Friday, November 12, 2004 3:53 PM said:

 At 21:32 12-11-2004, Chris W. Parker wrote:
 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']};
 
 Is that actually in the manual ??? If it is, where ?

Yes.

http://us2.php.net/manual/en/language.types.array.php

Search for More examples to demonstrate this fact then go down near
the bottom of that box and you'll see it.



Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php