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());
8 Years
Discussion Span
Last Post by tulipputih

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"]}

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

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.

Votes + Comments
Thanks for your explanation

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.