Jump to content


Formhandler , Hide Sql Error


9 replies to this topic

#1 Gast234

    Etomite Forum Fan

  • Member
  • Pip
  • 122 posts

Posted 10 January 2006 - 11:55 AM

delete

Edited by Gast234, 07 January 2008 - 11:37 PM.


#2 breezer

    Likes Etomite Forums!

  • Member
  • PipPip
  • 308 posts

Posted 10 January 2006 - 02:01 PM

most likely reason you are getting this error is you have not added your custom field to the $fields variable....

post the code so we can see what is going on :betterwink:

#3 Gast234

    Etomite Forum Fan

  • Member
  • Pip
  • 122 posts

Posted 10 January 2006 - 02:07 PM

delete

Edited by Gast234, 07 January 2008 - 11:37 PM.


#4 breezer

    Likes Etomite Forums!

  • Member
  • PipPip
  • 308 posts

Posted 10 January 2006 - 02:22 PM

after the code above you should be able to just return the $message I would think...

$bool = mysql_query("Insert into blablabla....");
if (!$bool) {
 $message = "Error";
} else {
 $message = "Success";
}

return $message;

or:

$output .=$message;


#5 Gast234

    Etomite Forum Fan

  • Member
  • Pip
  • 122 posts

Posted 10 January 2006 - 02:25 PM

delete

Edited by Gast234, 07 January 2008 - 11:38 PM.


#6 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 10 January 2006 - 02:30 PM

pebosi, on Jan 10 2006, 10:07 AM, said:

no,

i have a table with
- id (Primary key)
- email (unique)
- key

so if i add an entry with "mail@mail.de" and add this email again later, i got an error because of the "unique". But i need this field to be unique.

is there a way to get an message like this:

$bool = mysql_query("Insert into blablabla....");
if ($bool) {
  $message = "Success";
} else {
  $message = "Error";
}
In order to catch the duplicate key error you could either do the checking inline or by using a function... You can use the PHP mysql_errno() function to test for 1022, 1061, and 1062 which are the three most likely duplicate key error numbers... You can learn more about MySQL error codes here...

#7 Gast234

    Etomite Forum Fan

  • Member
  • Pip
  • 122 posts

Posted 10 January 2006 - 02:48 PM

delete

Edited by Gast234, 07 January 2008 - 11:38 PM.


#8 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 10 January 2006 - 03:12 PM

pebosi, on Jan 10 2006, 10:48 AM, said:

hm no...
is it able to hide the error?

to make it like this

$rs = $etomite->putIntTableRow($fields,$into);
if ($rs == 1) {
  $msg = "Success";
} else {
  $msg = "Error";
}

"mysql_query" was only an example....

Errors from almost any PHP function can be suppressed by adding the "@" character in front of the function call... The RTM release will accurately return false if the query result set is empty...

Edited by Ralph (rad14701), 10 January 2006 - 03:15 PM.


#9 Gast234

    Etomite Forum Fan

  • Member
  • Pip
  • 122 posts

Posted 10 January 2006 - 03:22 PM

delete

Edited by Gast234, 07 January 2008 - 11:38 PM.


#10 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 10 January 2006 - 04:18 PM

pebosi, on Jan 10 2006, 11:22 AM, said:

ok and where to add the "@" in $etomite->putIntTableRow($fields,$into); ??
Using @ in front of $etomite-> function calls won't work because Etomite has its own built-in error handling routines which would go into action before the results are returned... Those functions should return false on failuer so you can then check it by using if(!$rs) because the result will either be false or an array with a byte count greater than zero... Checking for zero is not always reliable, however, unless using === instead of ==, because of the possibility of the result being a negative number when dealing with MySQL function calls... It wouldn't be a good idea to suppress any parser error codes that Etomite may return as they signify a problem in your programming logic which needs to be addressed...

Edited by Ralph (rad14701), 10 January 2006 - 04:20 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users