Announcement

Collapse
No announcement yet.

Custom Error message on sc_exec_sql failure?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Error message on sc_exec_sql failure?

    I am doing a mysql insert during a form load.
    But it is possible for the key for the table to already be there.
    I am trying to just throw up an error message to let the user know he cant add that already.

    all I am is getting this..

    ERROR
    Error while accessing the database:
    Duplicate entry '1-2' for key 'PRIMARY'

    How do I throw an message to the user?

    Kev

  • #2
    Hi,
    since you don't get a return value from the sc_exec_sql() macro, I suggest using the sc_select() macro. Don't let you fool by the name.

    sc_select(success,"Insert ...");
    if($success === false)
    {
    echo "<script>alert('Ooops!');</script>";
    }

    jsb

    Comment


    • #3
      That works..
      Would have liked to make it a little better looking but it solves the duplicate mysql error..
      Thanks..

      Kev

      Comment


      • #4
        Instead of using the alert() function you can also redirect to a modal control application. Then you have all sorts of visual design options.

        jsb

        Comment

        Working...
        X