Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Mysql error posting

  • 26-02-2009 9:08pm
    #1
    Registered Users, Registered Users 2 Posts: 3,875 ✭✭✭


    When I try and insert a record into a table via a website, it is at times giving me a duplicate error notice.

    I set this up to avoid duplicates, and I am happy that this is happening

    Is it possible however to show for me to type my own content, instead of the error code been the only thing on the screen?

    I have been searching all over google but have found nothing,
    I must be using the wrong keywords,

    cheers.


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    When I try and insert a record into a table via a website, it is at times giving me a duplicate error notice.

    I set this up to avoid duplicates, and I am happy that this is happening

    Is it possible however to show for me to type my own content, instead of the error code been the only thing on the screen?

    I have been searching all over google but have found nothing,
    I must be using the wrong keywords,

    cheers.


    Yup - do a "SELECT" statement before you do the insert, and only run the insert if the number of rows returned is 0.


    SELECT * from TABLE WHERE id=key_id
    :
    if ($numRows==0) {
    INSERT INTO TABLE.....
    } else {
    PREPARE AND SHOW YOUR OWN ERROR MESSAGE
    }


  • Registered Users, Registered Users 2 Posts: 21,263 ✭✭✭✭Eoin


    If MySQL is returning a specific error number, you could also trap this with some try/catch code.


Advertisement