0

I have error on this line..
what should I change..thank you

mysql_query("INSERT INTO lesson (subject,year,learningArea,objectives,ability) VALUES 
                  ('<?php echo $onrow["subject"]', '<?php echo $onrow["year"]', '<?php echo $onrow["learningArea"]', '<?php echo $onrow["objectives"]', '<?php echo $onrow["ability"]' ") or die(mysql_error());
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by tulipputih
Featured Replies
  • you're already in PHP, you don't need to do [icode]<?php echo[/icode] Also, you're in double quotes so you must surround the [icode]$onrow["index"][/icode] with {} ie., [icode]{$onrow["index"]}[/icode] Read More

  • 1

    Try something like this [CODE=php]mysql_query('INSERT INTO lesson (subject, year, learningArea, objectives, ability) VALUES ("'.mysql_real_escape_string($onrow["subject"]).'", "'.mysql_real_escape_string($onrow["year"]).'", "'.mysql_real_escape_string($onrow["learningArea"]).'", "'.mysql_real_escape_string($onrow["objectives"]).'", "'.mysql_real_escape_string($onrow["ability"]).'"') or die(mysql_error());[/CODE] You may also want to post what was on the line before this as it too may also have an effect. Read More

1

you're already in PHP, you don't need to do <?php echo Also, you're in double quotes so you must surround the $onrow["index"] with {} ie., {$onrow["index"]}

Comments
thanks for your explanation :).it helps me understanding php better
1

Try something like this

mysql_query('INSERT INTO lesson (subject, year, learningArea, objectives, ability) VALUES ("'.mysql_real_escape_string($onrow["subject"]).'", "'.mysql_real_escape_string($onrow["year"]).'", "'.mysql_real_escape_string($onrow["learningArea"]).'", "'.mysql_real_escape_string($onrow["objectives"]).'", "'.mysql_real_escape_string($onrow["ability"]).'"') or die(mysql_error());

You may also want to post what was on the line before this as it too may also have an effect.

Comments
Thanks for your explanation
0

thanks cwarn23 and shawncplus..
I have tried before..
there is no error now..but the new record is not saved .
What I intend to do is to save a new record after customization.
I do not use update since this is a set of new record..(customised from the displayed record..

thank you for your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.