PHP Mysql connection failure?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
boagus1
Forum Newbie
Posts: 2
Joined: Fri Oct 19, 2007 6:42 pm

PHP Mysql connection failure?

Post by boagus1 »

Here is the code:

***** PLEASE USE

Code: Select all

AND OTHER TAGS WHEN POSTING CODE *****[/color]

Code: Select all

<?php
	

	$connection = mysql_connect("localhost", "root", "passio");
		if(!$connection) {
			die(Database connection failed; " . mysql_error());
	}
	
	
?>
<html>
<head>
<title>MsqlTry2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

</body>
</html>

I have WAMP5 1.7.3 correctly configured. MySQL and PHPMyAdmin setup with my databases correctly.
DreamWearver is my editor and I have repeatedly run this simple code and I get nothing.
A blank browswer screen. The username is correct and the password is wrong.
It should fail but it's not giving the error message.
Even with the correct password, I can not tell if it connected or not.

Someone plesae help
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP Mysql connection failure?

Post by Christopher »

boagus1 wrote:... I have repeatedly run this simple code and I get nothing.
A blank browswer screen.
Try adding this to the top of your script:

Code: Select all

error_reporting(E_ALL);
(#10850)
boagus1
Forum Newbie
Posts: 2
Joined: Fri Oct 19, 2007 6:42 pm

Post by boagus1 »

Still nothing but a blank browser screen
User avatar
gregwhitworth
Forum Commoner
Posts: 53
Joined: Tue Oct 09, 2007 1:00 am
Location: Wasilla, Alaska

Post by gregwhitworth »

This may be a dumb question, but where are your connection settings? Did you just delete them for this post, or is there really no connection settings.

--
Greg
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

die(Database connection failed; " . mysql_error());
You are missing the opening quote ;)
Post Reply