Page 1 of 1

Back to the basics

Posted: Fri Sep 17, 2004 11:53 am
by tazdog
I'm trying to get some connection issues resolved.
(yes I'm learning how to do this)

I have tried 3 different ways, but when I upload the code to my server, and display the page I get nothing in return.
So maybe I'm doing something wrong..

IF I read the code right I should get a die msg if I change the user name or passwd right.?
Well all I get is a blank screen when trying to goto the page.

Now if I do change the user name or passwd then I do get a die msg now, but is there a way to display a msg if I have connected..?

Here is the code I'm trying to use now:
<?php
$host = "MY IP";
$user = "MY USR NAME";
$pswd = "MY PASSWD";
$dbname = "MY DB";

$connect = mysql_connect($host, $user, $pswd)
or die("Could not connect: " . mysql_error());
$database = mysql_select_db("$dbname")
or die(MySQL_Error());
?>

thanks for your help..
Scott

Posted: Fri Sep 17, 2004 12:21 pm
by AGISB
Simply do it like this

Code: Select all

<?php
if (mysql_connect($host, $user, $pswd)) {
   echo 'connected';
} else {
  echo 'some error';
}

?>

Posted: Fri Sep 17, 2004 12:33 pm
by tazdog
Thank you very much

Scott