Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8975

Re: Connecting to MySQL server....

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: Connecting to MySQL server....
Date 2013-04-07 10:45 +0200
Message-ID <ascq0fF180nU1@mid.uni-berlin.de> (permalink)
References <ddfedcf5-8332-4072-9f6d-43ac47a5a187@googlegroups.com>

Show all headers | View raw


Am 07.04.2013 05:23, schrieb nag:
> Hi,
> 
> I have debconnect.php like the following...
> 
> 
> <?php
> 
> $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.
> 
>  Thank you.
> 
> 
> 
> 
Two more observations:

- you are using the deprecated mysql API, use mysqli or PDO instead.
- if the db server is local, it is a lot faster to connect to a path pointing to a
local socket

/Str.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Connecting to MySQL server.... nag <visitnag@gmail.com> - 2013-04-06 20:23 -0700
  Re: Connecting to MySQL server.... "J.O. Aho" <user@example.net> - 2013-04-07 09:06 +0200
  Re: Connecting to MySQL server.... The Natural Philosopher <tnp@invalid.invalid> - 2013-04-07 09:07 +0100
  Re: Connecting to MySQL server.... "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-04-07 10:45 +0200
    Re: Connecting to MySQL server.... Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-07 08:32 -0400
      Re: Connecting to MySQL server.... "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-04-07 15:09 +0200
        Re: Connecting to MySQL server.... The Natural Philosopher <tnp@invalid.invalid> - 2013-04-07 16:04 +0100
          Re: Connecting to MySQL server.... Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-07 22:14 -0400
        Re: Connecting to MySQL server.... Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-07 14:17 -0400
          Re: Connecting to MySQL server.... "Peter H. Coffin" <hellsop@ninehells.com> - 2013-04-07 20:08 -0500
            Re: Connecting to MySQL server.... Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-07 22:13 -0400

csiph-web