SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    save customised textboxes and as new record in database

    Hi,

    I have a page where the search result is displayed..
    & I have made the textboxes customised ,
    & I intend to save the customised textboxes as a new set of record in the database.

    I used INSERT INTO..
    however when I try to save it as a set of new record..
    nothing happened to the database.
    no record is added.
    PHP Code:
          if(isset($cmd)) {
             if(
    $cmd=="Save") {

          
    mysql_query("INSERT INTO lesson VALUES subject='$subject', year='$year'  where lessonID='$lessonID'");

                      }
               } 

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    What value does $cmd have? If you're gonna say "Save", are you sure of that?
    Do an echo of $cmd just before that if and check the result.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have error on this line..
    what should I change..thank you

    PHP Code:
    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());

  4. #4
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    mysql_query("INSERT INTO lesson (subject,year,learningArea,objectives,ability) VALUES('".$onrow['subject']."', '".$onrow['year']."', '".$onrow['learningArea']."', '".$onrow['objectives']."', '".$onrow['ability']."')") or die(mysql_error()); 

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks tendolla..
    I have tried as you suggested..there is no error..
    but still.. the set of new record is not saved in the database.
    thank you

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by guido2004 View Post
    What value does $cmd have? If you're gonna say "Save", are you sure of that?
    Do an echo of $cmd just before that if and check the result.
    Why don't you respond to this question? How can I help you if you ignore my questions?
    Quote Originally Posted by whitetulip View Post
    I have error on this line..
    what should I change..thank you

    PHP Code:
    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());
    You might want to tell what error you're getting. Although it's quite obvious this time Tendolla resolved this error for you, but now you'll have to answer my question again. Because if you don't get an error, and the data isn't inserted, then probably the command isn't executed at all, because the script doesn't enter the if-statement.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •