FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Connecting to MySQL server....
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Connecting to MySQL server.... [message #181033 is a reply to message #181031] Sun, 07 April 2013 08:07 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
On 07/04/13 04:23, nag wrote:
> 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.
>
>
>
>
FFS its the first example in the manual
http://php.net/manual/en/function.mysql-select-db.php


<?php

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}

// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: comparing arrays
Next Topic: PHP with MS SQL SERVER: is it suitable?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 06:46:33 GMT 2024

Total time taken to generate the page: 0.04829 seconds