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 all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back a page or two to re-sync the thread and this will then show latest posts. Thanks, Mike.

Mysql error posting

  • 26-02-2009 10: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,257 ✭✭✭✭Eoin


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


Advertisement