Try this for your connection: ---------------------------------------------------------------------------- ------------- <?
// Database constants define("DATABASE_HOST", "localhost"); define("DATABASE_USER", "root"); define("DATABASE_PASSWORD", "*YOUR_PASS*"); define("DATABASE_NAME", "*YOUR_DB_NAME*"); // Establish connection $dbLink = mysql_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD); if(!$dbLink) { print "Unable to connect to the database, please contact Sysadmin asap."; } else { $dbUse = mysql_select_db(DATABASE_NAME, $dbLink); } ?> ---------------------------------------------------------------------------- ----------------- Hope it helps ya, Craig "Anthony Ritter" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Using the script below, I was able to connect to a database named "contacts" > for > output. > > *However*, when I insert a [username] and [password] in place of the "" "", > I get: > > "Couldn't connect to the database" - eventhough I am able to connect to > mysql. > > How do I go about replacing the "" and "" to insert a password and username > so that it can be connected to a database? > > Any advice will be greatly appreciated. > TR > ................................................. > > <HTML> > <BODY> > <? > $connection=mysql_connect("localhost","",""); > if(!$connection) > { > echo "Couldn't connect."; > exit; > } > $db=mysql_select_db("contacts",$connection); > if(!$db) > { > echo "Couldn't connect to the database."; > exit; > } > $sql="SELECT * FROM leads"; > $mysql_result=mysql_query($sql, $connection); > $num_rows=mysql_num_rows($mysql_result); > > if($num_rows==0) > { > echo "There is no information"; > } > else > { > echo"<TABLE ALIGN=\"Center\" BORDER=\"1\">"; > echo"<TR><TH><FONT FACE =\"Arial\" SIZE=\"2\">First Name</TH><TH><FONT FACE > =\"Arial\" SIZE=\"2\">Last Name</TH><TH><FONT FACE =\"Arial\" > SIZE=\"2\">email</TH><TH><FONT FACE =\"Arial\" SIZE=\"2\">State</TH>"; > > while($row=mysql_fetch_array($mysql_result)) > { > $fname=$row["fname"]; > $lname=$row["lname"]; > $email=$row["email"]; > $state=$row["state"]; > $ID=$row["ID"]; > echo " <TR><TH><FONT FACE =\"Arial\" SIZE=\"2\">$fname</TH><TH><FONT FACE > =\"Arial\" SIZE=\"2\">$lname</TH><TH><FONT FACE =\"Arial\" > SIZE=\"2\">$email</TH><TH><FONT FACE =\"Arial\" > SIZE=\"2\">$state</TH></TR>"; > } > } > mysql_close($connection); > ?> > </BODY> > </HTML> > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php