Can't connect to MySQL using PHP, help please!!?

imported_Dave_G

New member
I tried the following, but it doesn't work and doesn't come up with any errors or anything.

<html>
<head>
</head>
<body>
<?php
$con = mysql_connect("127.0.0.1","root","password");
echo "Some Text";
?>
</body>
</html>

If I run this it just bring up a blank page and when I view page source it just says:
<html>
<head>
</head>
<body>

PHP works and MySQL works when I use command prompt.
Hey, thanks for answering,

I added that to it, same thing happened. Blank page and when I viewed page source it said:

<html>
<head>
</head>
<body>
 
You need more code to see if your connection is working or not.

if (!$con) {
echo "<p>Could not connect to the server.</p>";
echo mysql_error();
}else{
echo "<p>Connection successful!</p>";
}
 
Back
Top