Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: insert problem

  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    insert problem

    Having entered data to a form and then submitted it, the form script re-runs with the 'submitToDb sub-routine.

    I want this sub routine fristly, to write to the Db, creating a new record and adding the form data.

    This, however, doesn't seem to do it so can you please help. BTW, I am (trying), this in perl.

    Code:
    my $sql = "INSERT INTO Account ( `AccID` , `User` , `Password` , `Email` , `First_Name` , `Last_Name` , `My_Team_Name` , `League_Name` , `Budget` , `Rider_1_Name` , `Rider_1_Points` , `Rider_2_Name` , `Rider_2_Points` , `Team` , `Team_Points` , `Tyre` , `Tyre_Points` , `First_Retire` , `First_Retire_Points` , `Pole` , `Pole_Points` , `Total_Points` )
    VALUES (
    NULL , '', '', 'me@mydomain,com', '', '', '', '', '45', '', '0', '', '0', '', '0', '', '0', '', '0', '', '0', '0'
    )";
    Bazz
    Last edited by bazz; 07-26-2006 at 03:28 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried running this directly in a database client to see if the query itself works correctly?

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    What does: "doesn't seem to do" mean exactly? Do you get an error message or does nothing run?



    A small aside, if you are entering numeric data in your table, don't enclose it in quotes. Enclosing it in quotes creates a string out of it, mysql is then forced to change it to numeric data before inserting, thus slowing down your insert.

  • #4
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I can't detect that it does anything so I think nothing runs.

    I shall remember not to enclose numerical data in quotes but actually, that code was prppovided by phpMyAdmin

    bazz

  • #5
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Expounding on Kid Charming's post, print your $sql and copy and paste it in phpmyadmin and see if it runs. Also look up perls version of mysql_error(). Way back when I did perl I vaguely recall using it.

    Good luck;

  • #6
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If the query came from phpmyadmin, I'm going to assume it works (though, as has been pointed out already, phpmyadmin generates crappy queries). So, assuming that, you're problem's probably somewhere on the perl side. That block may not be running at all, you may be sending the query to the db incorrectly, etc. I'd post a larger chunk of code and have a mod move this to the Perl forum.


  •  

    Posting Permissions

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