Get support from Xavier Media
It is currently Sun Dec 08, 2013 3:48 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Custom errors?
PostPosted: Sun Oct 08, 2006 7:19 pm 

Points:
How can I make it so that instead of the ugly error that comes up I can have a custom message for error code 141? Error 141 means a duplicate is being added to the database, I want it to say something like "That username is already taken!" instead of the ugly "Duplicate entry 'blablabalavl' for key 2


Report this post
Top
  
Reply with quote  
 Post subject: Change MySQL Error
PostPosted: Mon Oct 09, 2006 3:00 pm 

Points:
I'm not sure, but I think you change the place in you PHP code from:

[php]<?php
...
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
...
?>[/php]

To:

[php]<?php
...
$result = mysql_query($query) or die('That username is already taken!');
...
?>[/php]

But I don't know for sure so don't quote me on this :P


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 09, 2006 5:12 pm 

Points:
Yes, but that means that string will display no matter what the error is, I need it to display different things depending on the error.


Report this post
Top
  
Reply with quote  
 Post subject: more errors...
PostPosted: Mon Oct 09, 2006 6:05 pm 

Points:
Then try something like this:


Make a function that takes all kinds of different errors and returns the user to the home page and shows the error. In this case it is a username error so that is the value we will pass the function.

[php]
<?php
...

if (!$result) {
gotohomepage_showerror('USERNAME_ERROR');
exit;
}

...
?>[/php]


The function could also except other values:

[php]
gotohomepage_showerror('DB_CONNECT_ERROR');
gotohomepage_showerror('PAGE_ERROR');
gotohomepage_showerror('GENERAL_ERROR');
ect...
[/php]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: Tue Oct 10, 2006 2:33 pm 

Points:
I ended up already doing that kind of thing, but thanks anyway, others may find it usefull.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Registered users: No registered users


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]