Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: Connecting to MySQL server.... Date: Sun, 07 Apr 2013 09:06:47 +0200 Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net CHCGt7Y0IC7p8sM56pg/lQWLfTivxu9pWy0CJhRbQkV6DeAELh Cancel-Lock: sha1:ADAQM/AbXAS4GWJic+QvO/BJT6k= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130326 Thunderbird/17.0.4 In-Reply-To: Xref: csiph.com comp.lang.php:8973 On 07/04/13 05:23, nag wrote: > Hi, > > I have debconnect.php like the following... > > > > $con=mysql_connect("localhost","root","") ; > > if(!$con){ > die('Error in Connection: '. mysql_error()); > } > mysql_select_db('newdb',$con); > > ?> > > If I give the password or user name wrong it is flashing the error, but if the database name wrong it is simply displaying a blank php file. How can I change the above to show the error even if the wrong database name is given. Check the example in the online documentation page. http://www.php.net/manual/en/function.mysql-select-db.php It's not the perfect way to do it. I would suggest you used try/catch and throw an exception, the catch would tell the user that there is some issues (do not show what went wrong, as that can be used to hack your site), keep in mind to generate the theme outside the try/catch, this way all pages will look nice no matter what happens. Use syslog http://www.php.net/manual/en/function.syslog.php to log what went wrong, now you have somewhere to find all the errors and without displaying it to the whole world. -- //Aho