Page 1 of 1

MySQL error

Posted: Mon Mar 08, 2010 12:18 am
by exentric
Hi..

I receive an error when my program tries to insert duplicate entry into the table.. I don't want my user to get scared on seeing the error.. I want to display it in a different way.. Could any one please help me how I can do that?

I tried using 'die' but no change..

Thanks for your assistance...

Re: MySQL error

Posted: Mon Mar 08, 2010 12:22 am
by jraede
What does your code look like? Do you have "...or die(mysql_error())" after the query?

Re: MySQL error

Posted: Mon Mar 08, 2010 12:26 am
by exentric
Hi jraede,

yes.. I gave like this..

$query4="insert into ...";
$result4=query($CDBC, $query4) or die(mysql_error());

But it didn't change anything...

Thanks for your help..

Re: MySQL error

Posted: Mon Mar 08, 2010 12:28 am
by jraede
Well, the mysql_error() function displays the error that you don't want users to see. Instead, you can change it to ...or die('You are trying to insert a duplicate value.'); However, just be aware that this will display whenever you get ANY MySQL error, even if it's not from a duplicate query. But, if all of your syntax is correct, the only error you should be getting is if it's a duplicate value, so you should be ok.

Re: MySQL error

Posted: Mon Mar 08, 2010 12:33 am
by exentric
.. I tried that also.. but the error page remains the same.. nothing gets changed

$result4=query($CDBC, $query4) or die('You are trying to inserta duplicate value.');

I am new to this.. Let me ask another doubt related to this please.. if I am giving mysql_error(), then will the error number be displayed in the error page ( I think it should right? ) ... But I am not seeing any error number getting displayed in the error page..

Re: MySQL error

Posted: Mon Mar 08, 2010 12:46 am
by jraede
Are you sure the error you're getting is a MySQL error and not a PHP error? What is the exact error you are getting?

Re: MySQL error

Posted: Mon Mar 08, 2010 12:49 am
by exentric
Please find the error below:
"

You are linking Paul OwensERROR with QUERY:
insert into ....

MYSQL ERROR:

Duplicate entry '155-1-2-3' for key 1

"

I just removed the 'insert' code.. :).. In the error page it will show me the complete insert statement..

Thanks for all your help...

Re: MySQL error

Posted: Mon Mar 08, 2010 1:31 am
by exentric
I hope someone could help me with this issue.. :)

Thanks..