FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Suppressing mysql error

 


kv
I am testing my website on my local machine. It is still in development stage and I am using php/mysql. If there is a mysql connection error, I am checking for the connection variable and displaying a proper error message. But even before it displays my error message, it displays an error message on browser thrown by mysql (MySQL Connection Failed: Access denied for user).

Can I suppress this message and display only my message?
Atomo64
add an @ on the connection code.... like this:
Code:

<?php
$link=@mysql_connect(blablabla);
?>

with that you are going to hide any message, and you can use the @ for everything, even for something like
Code:

<?php

if(@$_GET["page"]=="some_page")
{}
?>

even without checking if the $_GET["page"] variable is set... but I recommend you to only use the @ when you can't hide the message.
kv
Thanks. That helped. I also discovered that setting

error_reporting(0);

will suppress all the errors (which might be bad also. May take long time to debug.)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.