#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    16
    Rep Power
    0

    Value of MySql Database Field


    Hello:
    I have a MySql table with a field called MeetingNumber. It is the unique identifier (key) for the table so it adds the next number in sequence each time a record is added. I'm trying to print that value out in a confirmation email that gets sent and have used $MeetingNumber in the email. The email comes up blank though with that value. Any clues what I am doing wrong? The MeetingNumber value shows up in the database when I check it but does not show up in the email. Thanks for any help you can lend.

    cdr6800
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,167
    Rep Power
    4274
    php? or some other language?

    because you need to use php's mysql_insert_id() function to get the value of the auto_increment number that was assigned by the INSERT statement
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    16
    Rep Power
    0
    Originally Posted by r937
    php? or some other language?

    because you need to use php's mysql_insert_id() function to get the value of the auto_increment number that was assigned by the INSERT statement
    Hmmm..not sure I understand. Can you be more specific. Thanks for the reply.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    16
    Rep Power
    0
    Originally Posted by r937
    php? or some other language?

    because you need to use php's mysql_insert_id() function to get the value of the auto_increment number that was assigned by the INSERT statement
    Oh..sorry..by the way it is php.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,928
    Rep Power
    378
    Note that these sorts of queries are actively discouraged now, in favour of their mysqli or PDO alternatives.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    16
    Rep Power
    0
    Maybe this will illustrate more clearly. I have this statement:

    $query = "INSERT INTO AVorder VALUES ('$MeetingNumber','$Date','etc, etc, etc)

    $MeetingNumber is the auto increment field. It is showingup in database, but not email. So could you explain how I would use the function you are referring to? Thanks.

    cdr6800
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    157
    Rep Power
    89
    You shouldn't be sending a value to an auto increment field when performing an insert.

    You need to show the php code where you are generating the email. Your question would also be better targeted at the php forum.

    Comments on this post

    • ptr2void agrees
  14. #8
  15. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,167
    Rep Power
    4274
    thread moved to php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo